Radio buttons problem
2013-11-28, 04:44 PM, (This post was last modified: 2013-11-28, 04:46 PM by JaxTeller.)
#1
This the code for the first radio button

Code:
Private Sub PictureBox1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
        If TextBox1.Text = String.Empty And RadioButton1.Checked Or TextBox1.Text = String.Empty And RadioButton1.Checked = False Then
            MsgBox("Please add an email.", MsgBoxStyle.Critical, "Error!")

        ElseIf RadioButton1.Checked = False Then

            MsgBox("Please add ge.", MsgBoxStyle.Critical, "Error!")
        Else
            Timer1.Start()
        End If
    End Sub

The code do the following: if the textbox is empty but the radio button is checked he receive an error, if the textbox is filled but the radio button is not checked he receive and error, if nor the textbox is filled and nor the radion button is checked he receive an error. The only working combination is textbox filled and redio button checked, only than the timer 1 will start
My question is how to add the same code for the other 2 radio buttons?
Reply
2013-11-28, 04:56 PM,
#2
do elseif catch? im not pro, sorry
Reply
2013-11-28, 05:35 PM,
#3
(2013-11-28, 04:44 PM)andrewg03 Wrote: This the code for the first radio button

Code:
Private Sub PictureBox1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
        If TextBox1.Text = String.Empty And RadioButton1.Checked Or TextBox1.Text = String.Empty And RadioButton1.Checked = False Then
            MsgBox("Please add an email.", MsgBoxStyle.Critical, "Error!")

        ElseIf RadioButton1.Checked = False Then

            MsgBox("Please add ge.", MsgBoxStyle.Critical, "Error!")
        Else
            Timer1.Start()
        End If
    End Sub

The code do the following: if the textbox is empty but the radio button is checked he receive an error, if the textbox is filled but the radio button is not checked he receive and error, if nor the textbox is filled and nor the radion button is checked he receive an error. The only working combination is textbox filled and redio button checked, only than the timer 1 will start
My question is how to add the same code for the other 2 radio buttons?

PictureBox1
TextBox1
RadioButton1


All highlighted words have 1 in their end which means you have only 1 picturebox,1 textbox, and 1 radiobutton now as you want to add more then 1 you will find there name as textbox2,textbox3...textboxN now what you have to do is copy that code and change the code according to the name of the tool property.. on any event you wish to like.. if it's not enough then let me know where you're getting error.?
Reply
2013-11-28, 06:16 PM,
#4
yes i tried that but what it does it shows me the error msgbox 3 times for every radio button

Code:
Private Sub PictureBox1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
        If TextBox1.Text = String.Empty And RadioButton1.Checked Or TextBox1.Text = String.Empty And RadioButton1.Checked = False Then
            MsgBox("Please add an email.", MsgBoxStyle.Critical, "Error!")

        ElseIf RadioButton1.Checked = False Then

            MsgBox("Please add ge.", MsgBoxStyle.Critical, "Error!")
        Else
            Timer1.Start()
        End If

        If TextBox1.Text = String.Empty And RadioButton2.Checked Or TextBox1.Text = String.Empty And RadioButton2.Checked = False Then
            MsgBox("Please add an email.", MsgBoxStyle.Critical, "Error!")

        ElseIf RadioButton2.Checked = False Then

            MsgBox("Please add ge.", MsgBoxStyle.Critical, "Error!")
        Else
            Timer2.Start()
        End If

        If TextBox1.Text = String.Empty And RadioButton3.Checked Or TextBox1.Text = String.Empty And RadioButton3.Checked = False Then
            MsgBox("Please add an email.", MsgBoxStyle.Critical, "Error!")

        ElseIf RadioButton3.Checked = False Then

            MsgBox("Please add ge.", MsgBoxStyle.Critical, "Error!")
        Else
            Timer3.Start()
        End If
    End Sub
Reply
2013-11-30, 10:18 PM,
#5
(2013-11-28, 06:16 PM)andrewg03 Wrote: yes i tried that but what it does it shows me the error msgbox 3 times for every radio button

Code:
Private Sub PictureBox1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
        If TextBox1.Text = String.Empty And RadioButton1.Checked Or TextBox1.Text = String.Empty And RadioButton1.Checked = False Then
            MsgBox("Please add an email.", MsgBoxStyle.Critical, "Error!")

        ElseIf RadioButton1.Checked = False Then

            MsgBox("Please add ge.", MsgBoxStyle.Critical, "Error!")
        Else
            Timer1.Start()
        End If

        If TextBox1.Text = String.Empty And RadioButton2.Checked Or TextBox1.Text = String.Empty And RadioButton2.Checked = False Then
            MsgBox("Please add an email.", MsgBoxStyle.Critical, "Error!")

        ElseIf RadioButton2.Checked = False Then

            MsgBox("Please add ge.", MsgBoxStyle.Critical, "Error!")
        Else
            Timer2.Start()
        End If

        If TextBox1.Text = String.Empty And RadioButton3.Checked Or TextBox1.Text = String.Empty And RadioButton3.Checked = False Then
            MsgBox("Please add an email.", MsgBoxStyle.Critical, "Error!")

        ElseIf RadioButton3.Checked = False Then

            MsgBox("Please add ge.", MsgBoxStyle.Critical, "Error!")
        Else
            Timer3.Start()
        End If
    End Sub


did you add another radio buttons?

[Image: 8vu5.png]
"You don't get another chance, Life is not a nintedo game" -
-Eminem-

Still Paying For Google +1's?
Why Not Delivering Them Yourself?
Start Now!


Reply
2013-11-30, 11:58 PM,
#6
(2013-11-30, 10:18 PM)Harpush Wrote:
(2013-11-28, 06:16 PM)andrewg03 Wrote: yes i tried that but what it does it shows me the error msgbox 3 times for every radio button

Code:
Private Sub PictureBox1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
        If TextBox1.Text = String.Empty And RadioButton1.Checked Or TextBox1.Text = String.Empty And RadioButton1.Checked = False Then
            MsgBox("Please add an email.", MsgBoxStyle.Critical, "Error!")

        ElseIf RadioButton1.Checked = False Then

            MsgBox("Please add ge.", MsgBoxStyle.Critical, "Error!")
        Else
            Timer1.Start()
        End If

        If TextBox1.Text = String.Empty And RadioButton2.Checked Or TextBox1.Text = String.Empty And RadioButton2.Checked = False Then
            MsgBox("Please add an email.", MsgBoxStyle.Critical, "Error!")

        ElseIf RadioButton2.Checked = False Then

            MsgBox("Please add ge.", MsgBoxStyle.Critical, "Error!")
        Else
            Timer2.Start()
        End If

        If TextBox1.Text = String.Empty And RadioButton3.Checked Or TextBox1.Text = String.Empty And RadioButton3.Checked = False Then
            MsgBox("Please add an email.", MsgBoxStyle.Critical, "Error!")

        ElseIf RadioButton3.Checked = False Then

            MsgBox("Please add ge.", MsgBoxStyle.Critical, "Error!")
        Else
            Timer3.Start()
        End If
    End Sub


did you add another radio buttons?

i solved the problem, i selected the first radio button as checked and didn't need this code anymore.
Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  Register bot - Captcha problem honeydew 5 1,529 2016-09-13, 12:01 AM
Last Post: zozo31
  Site problem Mesmero44 3 926 2016-04-26, 11:44 PM
Last Post: Eion
  Simple But Big Problem for Me Cold'Play 12 890 2015-02-28, 07:52 PM
Last Post: Techman
  (HELP) A href problem DondotheGreat 11 750 2015-02-03, 07:06 AM
Last Post: jugnujinga
  small problem with css dzep 1 369 2014-07-10, 05:27 PM
Last Post: Stone_Heart





About Us | Contact Us | CPA Elites | Advertise | Stats | Staff Team

© 2013-2017 CPA Elites Ltd
Enhanced by MyBB and WallBB
Return to top