简体   繁体   中英

checkbox selected values in comma sepearted string in textbox using vb.net !

I have 3 checkboxes and 1 textbox

checkbox1, checkbox2, checkbox3

when i check first checkbox1 and then checkbox3 then in textbox it will appear as 1,3 exactly........ !!

using vb.net only.........

Try:

Private Sub CheckBox_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox3.CheckedChanged, CheckBox2.CheckedChanged, CheckBox1.CheckedChanged

    Dim sb As New System.Text.StringBuilder
    sb.Append(CStr(IIf(CheckBox1.Checked, "1 ", "")))
    sb.Append(CStr(IIf(CheckBox2.Checked, "2 ", "")))
    sb.Append(CStr(IIf(CheckBox3.Checked, "3 ", "")))
    TextBox1.Text = sb.ToString.Trim
End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM