**Hello Guys...
I am building an application in which there are 3 radio buttons. And i want to add password authentication on one of the radio button. So, I have inserted an Input box in my code and ask for the password from the user, Its working fine if we insert the correct password but when user enters wrong password or the user clicks on the cancel button it appears again automatically, moreover when i click on another radio button in which i have not inserted any password authentication, it asks for the password on other radio button also.

My code for password authentication is:**

 Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged

        Dim resu As String
        resu = InputBox("Enter Password", "Access Restricted")
        If (Windows.Forms.DialogResult.OK And resu = "uhg123") Then
            ComboBox1.Enabled = True
            ComboBox1.Items.Clear()
            data1 += 1
                If (data1 = 1) Then
                  Module1.connect()
                  Me.fillcombo()
                End If

        ElseIf Windows.Forms.DialogResult.OK And resu <> "uhg123" Then
            MsgBox("Wrong Password")
            Me.RadioButton3.Checked = False

        ElseIf Windows.Forms.DialogResult.Cancel Then
            Me.RadioButton3.Checked = False
        End If

Kindly See to it. Your response would be appreciated.

You are calling this from the CheckChanged event.

That means when it will repeat the code when you use:

Me.RadioButton3.Checked = True

When you are setting the value, the application will raise the CheckChanged event.

This will be an infinite loop, right?

You can try to drop the code in the radio button's Click event.

Hope this helps!

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.