2 Replies - 5729 Views - Last Post: 14 June 2010 - 06:53 AM Rate Topic: -----

#1 joker_1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 06-June 10

Open new form after login

Posted 13 June 2010 - 09:16 PM

Hi,

Im running a login screen (code below) but when a user logs in, how can i get visual basic 2008 express to pop up a new form. I.E. user logs onto system, then a program loads up.



Code -

Public Class Login

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

End Sub

Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = "admin" And TextBox2.Text = "admin" Then
MsgBox("You Are Lgoed In!")


Else
MsgBox("Incorrect username/password", MsgBoxStyle.Critical, "")

End If
If TextBox1.Text = "" And TextBox2.Text Then
MsgBox("Please Enter Username And Password", MsgBoxStyle.Critical, "")
End If
End Sub
End Class


Thanks,

Lyndon Pace
lyndon.pace@education.nsw.gov.au

Is This A Good Question/Topic? 0
  • +

Replies To: Open new form after login

#2 demausdauth  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 175
  • View blog
  • Posts: 636
  • Joined: 03-February 10

Re: Open new form after login

Posted 13 June 2010 - 09:33 PM

The best way that I have found to do this is, in the project properties, go to the Application tab. Click the 'View Application Events' button. This will open MyApplication partial class. Create the Startup event and here you can put code to show the Login form as a dialog box. If the login is successful then the application can finish loading, if the login is not successful then you can cancel the startup event using the 'e' argument.

I have used this approach very successfully in 2 applications.
Was This Post Helpful? 2
  • +
  • -

#3 FahedDotnet  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 58
  • Joined: 25-February 10

Re: Open new form after login

Posted 14 June 2010 - 06:53 AM

If TextBox1.Text = "admin" And TextBox2.Text = "12345" Then
MsgBox("You Are Lgoed In!")
Form2.Show()
Else
MsgBox("Incorrect username/password", MsgBoxStyle.Critical, "Error")
End If
If TextBox1.Text = Nothing And TextBox2.Text = Nothing Then
MsgBox("Please Enter Username And Password", MsgBoxStyle.Critical, "Error")
End If

This post has been edited by FahedDotnet: 14 June 2010 - 07:31 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1