i have 4 textbox in my application..if i did't fill any data in that 4 textbox i want to show error like ..please enter necessary fields..i dono how to check whether the field is filled or empty..and also i used 4 radio buttons in my program. out of 4 i want choose 2 radio buttons. if i did't choose any radio button i want to show error.. what is the code for above questions...
how to show error in vb.net for textbox and radio button when i did't fill the textbox?
m working in windows application for vb.net...
Scott LyslePosted Sep 3, 2007, 1:18 AM
Check the textboxes for an empty string and check the radiobutton's checked properties; the following will check to see if all four textboxes are empty and if both radiobuttons 1 and 2 are unchecked and radiobuttons 3 and 4 are unchecked:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If TextBox1.Text = String.Empty And TextBox2.Text = String.Empty _ And TextBox3.Text = String.Empty And TextBox4.Text = String.Empty Then MessageBox.Show("Enter something in at least one of the textboxes", "Adios") Return End If If (RadioButton1.Checked = False And RadioButton2.Checked = False) Then MessageBox.Show("Pick either radiobutton1 or radiobutton2", "Adios") Return End If If (RadioButton3.Checked = False And RadioButton4.Checked = False) Then MessageBox.Show("Pick either radiobutton3 or radiobutton4", "Adios") Return End If MessageBox.Show("Good job, Sparky!") End Sub