Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to concatenate strings and multiline text box? 1

Status
Not open for further replies.

markdmac

MIS
Dec 20, 2003
12,340
US
I have a lot of experience with VBScript but am new to VB.NET. I am using VB Express Edition 2008.

I've created a form that has a number of text boxes, one of which is a multi line text box. I've added a button which should trigger concatenating all the text together.

In my form I have the following code:
Code:
Dim Author, Title, Description As String
Author = txtAuthor.Text
Title = txtTitle.Text
Description = txtDescription.Text
Dim CodeBlock() As String = Me.txtCodeBlock.Lines
I want to set a variable called "report" to be equal to the string concatonation of Author & Title & Description & CodeBlock but I am having problems. I've tried using & and + to concatenate but am getting errors that the operator is not defined for tyes 'String' and 1-dimension array of String.

Can anyone assist me with this?

Best regards,
Mark
 
The .Lines function of your txtCodeBlock TextBox returns an array of strings. It gives you one string for each line in your TextBox. It basically takes a string, and splits it out into multiple strings for each line. So when you try to concatenate a string with an array of strings, it doesn't work. I would suggest you forgo the array in this case and work with single strings only. For example:

Code:
Dim SomeVariable As String = txtAuthor.Text & txtTitle.Text & txtDescription.Text & txtCodeBlock.Text
 
Worked like a charm thanks!

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top