By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,083 Members | 1,608 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,083 IT Pros & Developers. It's quick & easy.

String.Concat(?, ?) Help please.

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.