I’m totally new to Visual Studio, and I have to create a simple project for class, which has 2 forms. The 1st Form is a Username & Password form that opens a second form when the Username & Password are entered.
It works, kind of, except the Form that opens is not the Form I’ve created (called “TheMainForm”). It’s just a blank Form.
I’ve referenced a VB book, Google, and even the VB for Dummies website, and they all point to the same code:
Dim oForm As TheMainForm oForm = New TheMainForm() oForm.Show() oForm = Nothing
However, when I type this in, VB keeps saying “TYPE: THE MAIN FORM IS NOT DEFINED”
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnlogin.Click Dim strUsers, strPassword As String Dim oForm As TheMainForm oForm = New TheMainForm() oForm.Show() oForm = Nothing strUsers = txtUsername.Text strPassword = txtPassword.Text If strUsers = "Jean Brady" And strPassword = "M1" Then TheMainForm.Show() Else : TheMainForm.Hide() End If End Sub
I must be really dumb because I just can’t understand why this isn’t working when every resource says it should.
Can anyone tell me what I’m doing wrong?
Many thanks in advance.
Kyle