Monday, 19 December 2011

Copy TextBox Content To Another using Checkbox


For this, I am using Two textboxes named txtpermanentadd and txtpresentadd and a checkbox named checkbox1. Screenshot given below.
To make textbox for typing  address, change multiline property of textbox to True.
Write the below code in the Checkedchanged event of Checkbox1
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
        If CheckBox1.Checked = True Then
            If txtPermanantadd.Text <> "" Then
                txtPresentadd.Text = txtPermanantadd.Text
            Else
                MessageBox.Show("Permanent Address field is empty")
                CheckBox1.Checked = False
                Exit Sub
            End If
        Else
            txtPresentadd.Text = ""
        End If
    End Sub
The permanentaddress is copied to presentaddress when the checkbox1 is checked, otherwise clear the content in the present address field.

No comments:

Post a Comment