textbox question

daveofgv

Well-known member
Joined
Sep 17, 2008
Messages
218
Location
Dallas, TX
Programming Experience
1-3
I have a form with a textbox1 where the user can either put a demo version code or the full version code. (both product ID's are hard coded).

I have a message box saying demo or full version depending on which code the user enters. However, when something other then the two numbers are entered in the textbox1 I would like a message box appear saying "Wrong Product Number. Please Try Again".
I have " If TextBox1.Text = "" Then" but that only makes the message box appear if nothing is entered into the textbox1.

VB.NET:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        If TextBox1.Text = "4321" Then 'Full Version Code
            MessageBox.Show("Full Version Enabled")
            Button3.Enabled = True
            Main.Button1.Visible = True
            Main.Button6.Visible = False
        Else
            If TextBox1.Text = "1234" Then 'Demo Verison Code
                MessageBox.Show("Demo Version Enabled.  To purchase the full version please buy Specific Site Plus")
                Button3.Enabled = True
                Main.Button1.Visible = False
                Main.Button6.Visible = True
            Else
                If TextBox1.Text = "" Then
                    MessageBox.Show("Wrong Product ID. Please Try Again")
                End If
            End If
        End If
    End Sub

Anyone know what to enter to make a message box appear if something that is not the correct number is entered.

Thanks in advanced
daveofgv
 
Last edited by a moderator:
VB.NET:
		If TextBox1.Text = "4321" Then
			'Full Version Code
		ElseIf TextBox1.Text = "1234" Then
			'Demo Version Code
		Else
			MessageBox.Show("Wrong Product ID.  Please Try Again.")
		End If
 
Last edited:
A TextBox is a Windows Forms control, so questions regarding TextBoxes belong in the Windows Forms forum. This question is not really about TextBoxes though; it's about If statements. As such it belongs in the VB.NET General forum. The VS.NET section is for IDE questions, not language or application questions. Moved.
 
Back
Top