469,336 Members | 5,656 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,336 developers. It's quick & easy.

String.Concat(?, ?) Help please.

Ok,
I have a webform that has these checkboxes:

1. something
2. something else
3. and something else

When the user clicks on the checkbox, I want all of the selections to go
into a textbox if all are checked. But currently, just the last
selection is going in. Here's the code I have:

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click
If CheckBox1.Checked = True Then
TextBox6.Text = String.Concat(SPString, SPString1)
End If
If CheckBox2.Checked = True Then
TextBox6.Text = String.Concat(SPString, SPString2)
End If
If CheckBox3.Checked = True Then
TextBox6.Text = String.Concat(SPString, SPString3)
End If
End Sub

Any help is appreciated.
Thanks,
Trint
.Net programmer
tr********@hotmail.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #1
1 1731
Trint,
Have you tried something like:

TextBox6.Text = SPString
If CheckBox1.Checked = True Then
TextBox6.Text = String.Concat(TextBox6.Text, SPString1)
End If
If CheckBox2.Checked = True Then
TextBox6.Text = String.Concat(TextBox6.Text, SPString2)
End If
If CheckBox3.Checked = True Then
TextBox6.Text = String.Concat(TextBox6.Text, SPString3)
End If
Depending on what SPString really is, you may need it with each
String.Concat.

Also I find it "cleaner" to use the concatenation operator "&" instead of
String.Concat. Remember the concatenation operator uses String.Concat
internally so there is no performance gain or loss to use &.

Plus in this case I would consider using concatenation assignment "&="
instead of just &.

TextBox6.Text = SPString
If CheckBox1.Checked = True Then
TextBox6.Text &= SPString1
End If
If CheckBox2.Checked = True Then
TextBox6.Text &= SPString2
End If
If CheckBox3.Checked = True Then
TextBox6.Text &= SPString3
End If
Note these two lines are the same:

TextBox6.Text = TextBox6.Text & SPString1

TextBox6.Text &= SPString1

Hope this helps
Jay
"Trint Smith" <tr********@hotmail.com> wrote in message
news:eG*************@TK2MSFTNGP12.phx.gbl... Ok,
I have a webform that has these checkboxes:

1. something
2. something else
3. and something else

When the user clicks on the checkbox, I want all of the selections to go
into a textbox if all are checked. But currently, just the last
selection is going in. Here's the code I have:

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click
If CheckBox1.Checked = True Then
TextBox6.Text = String.Concat(SPString, SPString1)
End If
If CheckBox2.Checked = True Then
TextBox6.Text = String.Concat(SPString, SPString2)
End If
If CheckBox3.Checked = True Then
TextBox6.Text = String.Concat(SPString, SPString3)
End If
End Sub

Any help is appreciated.
Thanks,
Trint
Net programmer
tr********@hotmail.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Jesse | last post: by
7 posts views Thread by Eddy Soeparmin | last post: by
1 post views Thread by David Tomlinson | last post: by
2 posts views Thread by Raghu Raman | last post: by
2 posts views Thread by Trint Smith | last post: by
6 posts views Thread by LCD | last post: by
2 posts views Thread by almurph | last post: by
10 posts views Thread by ruffiano | last post: by
6 posts views Thread by djm | last post: by
15 posts views Thread by rajash | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Marylou17 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.