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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Working with StringBuilders

Status
Not open for further replies.

sthmpsn1

MIS
Sep 26, 2001
456
US
I am starting to work with a stringbuilder for the first time and wondering why this isn't displaying any text
Here is my code

Dim dependentsnames as StringBuilder
dependentsnames = New StringBuilder(child1.text)
dependentsnames.Append("," & child2.text)
label1.text = ( dependentsnames.ToString() )

Textbox child1, and child2 both contain text. I want to display both textboxes with a comma in between them.
 
Not exactly sure what is crapping out. but I would like to point out. Correct me if I am wrong but, doesn't the & nullify the reason for using the stringbuilder. The & is what makes concatinating bad. To fix it just change the code a little to this.

Dim dependentsnames as StringBuilder
dependentsnames = New StringBuilder(child1.text)
dependentsnames.Append(",")
dependentsnames.Append(child2.text)
label1.text = dependentsnames.ToString()


I also took the brackets off of the code where you assign the labels text since they aren't needed.

Try that I guess. Are you able to debug by stepping through your code? If so I would try that to see what is happening on the label.text line. That'l do donkey, that'l do
[bravo] Mark
 
I was able to figure it out. It always helps when you actually call the sub you have code in :( Thanks for the code suggestions. I used them very wisely. :)
 
lol it does sometimes help to call the sub yes. That'l do donkey, that'l do
[bravo] Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top