Form Switching

xero

Member
Joined
Nov 8, 2004
Messages
12
Programming Experience
1-3
Well let me start out by saying im new to vb.net so bare with me...

I am curious how to do the following:

When program is opened, goes directly to frm_login
When password and username are correct goes to frm_main (this is the main window)

What i am doing wright now is this:

When program is opened:

Frm_Main is called...

sub frm_Main_Load
Dim Formlogin As New frm_Login()
If loginVerified = false then
formLogin.Show()
counter_login.Enabled = True
end sub
sub Counter_Login_Elasped
Me.Visible = False
end sub

Once Frm_Main is called it goes directly to frm_Login... I had to use the counter in order to do this because for whatever reason the main form kept staying visible.

frm_Login

Sub ButtonClick
Dim FormMain as New Frm_Main
If tbx_user.text = "Username" And tbx_password.Text = "Password" Then
LoginVerified = True
FormMain.visible = true
Me.Close()
else
msgbox("Username or Password is incorrect")
end if
end sub



My problem right now is whenever i run the app it closes and goes through right, but when i go to close the main window after logging in it doesn't close the application.
I believe this is because i am declaring FormMain as a "NEW" form vs using the current form that is invisable.... What can i do to correct this problem???

Also what could i do to not have to use the timer to get the frm_Main form to close?

Thanks!!!
 
try this one.
VB.NET:
 'in the main form
 public logged as boolean=false
 'in the form load
 dim x as new login()
 me.addownedform(x)
 x.showdialog()
 if logged = false then
    application.doevents()
 end if
 
 'in the login form
 dim m as mainform
 'in the formload
 m= me.owner
 'in button click
   If tbx_user.text = "Username" And tbx_password.Text = "Password" Then
 m.logged = true
  close()
 else
   msgbox("Username or Password is incorrect")
   end if
   end sub
 
Ok, the problem im facing is somewhat similar to what you started off with. My verification, however is from a URL. Below is the code ive got to check it. I know something is wrong, just that ive done a heap of crawls for everything im after, and this thread has been the closest =|

VB.NET:
[size=2][color=#0000ff]Private[/color][/size][size=2][color=#0000ff]Sub[/color][/size][size=2] txtURL_TextChanged([/size][size=2][color=#0000ff]ByVal[/color][/size][size=2] sender [/size][size=2][color=#0000ff]As[/color][/size][size=2][color=#0000ff]Object[/color][/size][size=2], [/size][size=2][color=#0000ff]ByVal[/color][/size][size=2] e [/size][size=2][color=#0000ff]As[/color][/size][size=2] System.EventArgs) [/size][size=2][color=#0000ff]Handles[/color][/size][size=2] txtURL.TextChanged
 
[/size][size=2][color=#0000ff]If[/color][/size][size=2] txtURL.Text = ".../chatroom.asp" [/size][size=2][color=#0000ff]Then
 
[/color][/size][size=2]Main.WindowState = FormWindowState.Normal
 
Main.Show()
 
[/size][size=2][color=#0000ff]Me[/color][/size][size=2].Visible = [/size][size=2][color=#0000ff]True
 
[/color][/size][size=2][color=#0000ff]Else
 
[/color][/size][size=2]lblIncorrect.Visible = [/size][size=2][color=#0000ff]True
 
[/color][/size][size=2][color=#0000ff]End[/color][/size][size=2][color=#0000ff]If[/color][/size][size=2][color=black]
[/color][/size]

Basically, what its not doing, is loading up the Main form, and keeping the Login form open.

When the login is validated by sending a login string to the server, it returns with chatroom.asp, it it doesnt, just comes back with a standard Login.asp. I get the browser control's URL sent to the Textbox as soon as its finished navigating.

VB.NET:
[size=2][color=#0000ff]Private[/color][/size][size=2][color=#0000ff]Sub[/color][/size][size=2] cmdLogin_Click([/size][size=2][color=#0000ff]ByVal[/color][/size][size=2] sender [/size][size=2][color=#0000ff]As[/color][/size][size=2] System.Object, [/size][size=2][color=#0000ff]ByVal[/color][/size][size=2] e [/size][size=2][color=#0000ff]As[/color][/size][size=2] System.EventArgs) [/size][size=2][color=#0000ff]Handles[/color][/size][size=2] cmdLogin.Click[/size]
[size=2]
brwLogin.Navigate(".../Login.asp?func=1&Submit=Login&username=" + txtUsername.Text + "&password=" + txtPassword.Text)
 
txtURL.Text = brwLogin.LocationURL
 
[/size][size=2][color=#0000ff]End[/color][/size][size=2][color=#0000ff]Sub[/color][/size][size=2][color=#0000ff][color=#000000]
[/color][/color][/size]

Anyone point out what ive done wrong there ? =|

Thanks
 
Wait, nevermind, as i expected, id work it out after a made a public post :eek:

Thanks anyways, logs in fine, now i just have to add my basic features like posting, etc, which i have fitted into previous versions. :)
 

Latest posts

Back
Top