Member Avatar for Micheal87

Hi, I have a question, how can I achieve this, like I have declared 3 variable as string, each checkbox has a variable that will be created if clicked also when checked it will put the corresponding textbox.text into it. Now the problem is I need to make sure that the first one that will be selected will be the first one that will be paste thanks to the variable, the seond checked and third checked same thing. This is the code

 Private Sub CheckBox2_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox2.CheckedChanged
        Dim fntext As String
        Dim artext As String
        Dim dltext As String
        If CheckBox3.Checked = True Then
            fntext = TextBox1.Text
        ElseIf CheckBox4.Checked Then
            artext = TextBox4.Text
        ElseIf CheckBox5.Checked Then
            dltext = TextBox6.Text
        End If
    End Sub
    TextBox7.Text += fntext & vbCrLf & artext & vbCrLf & dltext
End Class
Member Avatar for Micheal87

I change all the code to give the same effect, also put it to a button.

Dim fntext As String = TextBox1.Text.ToString
        Dim artext As String = TextBox4.Text.ToString
        Dim dltext As String = TextBox6.Text.ToString
        If CheckBox3.Checked = True Then
            TextBox7.Text += fntext & vbCrLf
        End If
        If CheckBox3.Checked = False Then

        End If
        If CheckBox4.Checked = True Then
            TextBox7.Text += artext & vbCrLf
        End If
        If CheckBox4.Checked = False Then

        End If
        If CheckBox5.Checked = True Then
            TextBox7.Text += dltext & vbCrLf
        End If
        If CheckBox5.Checked = False Then

        End If

Employ CheckChanged event:

    Private Sub CheckBox3_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox3.CheckedChanged
        If CheckBox3.Checked = True Then
            TextBox7.Text += fntext & vbCrLf
        End If
    End Sub
    Private Sub CheckBox4_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox4.CheckedChanged
        If CheckBox4.Checked = True Then
            TextBox7.Text += artext & vbCrLf
        End If
    End Sub
    Private Sub CheckBox5_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox5.CheckedChanged
        If CheckBox5.Checked = True Then
            TextBox7.Text += dltext & vbCrLf
        End If
    End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.