Switching Subs?

xcorp

Active member
Joined
Jul 10, 2003
Messages
35
Location
bc canada
Hey

Im wondering if there is a way to change between subs?
Well I know there is a way but how?

I was just ditsing around the other day with arrays and colors when I came accross button clicking.. happening.. stuff.

I made a little log in thing, and it went as follows

LOGIN

Username
<textbox>

<button>

and the <button> and <textbox> are textboxes in Visual Basic and stuff.

You enter the username into the text box and then press the button where username (label2) changes to "Password" and you have to enter the correct password into the now blank textbox.

Only thing is, I want you to have to press the button twice, once to change to password and once again to complete the login..

I have two buttons on top of each other, and one is invisible that I can be made visible later and the other one invisible so.. you press the button twice and preform different acctions. But really your pressing two different buttons. I know this is lame and crude but I dunno anything and im using all my brain power here
:p



Im not sure if your with me here but what I have so for is like.. well Im on a dif computer so Im going to do a ROUGH draft of my code.


Private sub button1_click (handled by blah blah blah...)

if textbox1.text = "X-Corp" then goto password
if textbox1.text <> "X-Corp" then goto wrong

wrong:
\\ This isnt part of the coding but, label1 is the "Login" at the top of my form

label1.text = "Incorrect!"
application.doevents()
system.threading.thread.sleep(2000)
me.close()

password:

button1.visible = false
button2.visible = true
label2.text = "Password"
textbox1.text = ""

\\ NOW THIS IS WHERE I WANNA CHANGE TO MY BUTTON 2 SUB

end sub

private sub button2_click (handled by blah blah blah..)

if textbox1.text = "ritb" then goto logincorrect
if textbox1.text <> "ritb" then goto wrong

wrong:

label1.text = "Incorrect!"
application.doevents()
system.threading.thread.sleep(2000)
me.close()


logincorrect:

label1.text = "Login Successfull!"
application.doevents()
system.threading.thread.sleep (2000)
goto menu

menu:

\\ What I wanna do with my programm and stuff.. menu.. do this.. do that blah blah.

Now I know my coding is very "Streight" forward and not using any smart stuff, its not EXACTLY like i have in my program. I cant access the file right now.

Anywho - I hope you got the jist of what I"m asking.


How to switch to another sub!!

That was quite a simple question brought into huge format and I aplogize.

Im 13 years old.... And Not the smartest one in the box

Any help would be appriciated!!
 
Last edited by a moderator:
hey, listen, heres what you could do, from what i understood in your directions, you have a textbox that says "Username" and when you type in your correct username and press the button, the "username" changes to "password".. and you type in your password.

heres what i would do:

I would use an If statment to check weather you already clicked it once! There is something called a boolean - its just "True" or "false" values
so what i would do is, declare a boolean called "ClickedAlready" in the declarations space, right below system.windows.forms.form: by default its true

Dim ClickeAlready As boolean

Code:
Private sub button1_click (handled by blah blah blah...)

If ClickedAlready = False Then
Do whatever you want
End If

If ClickedAlready = True Then
Check for your password and stuff
End If

//when you click it for the first time, this is what happens:
ClickedAlready = True

End Sub

I hope this is what you want. i dont understand the purpose of this:
application.doevents()
system.threading.thread.sleep(2000)
u dont need to do multithreading in this app! :)

by the way, dont let your age intimidate u, im only 14! by the way, for beginning VB.NET help check my site out
vbprogramming.8k.com (this is in my signature but i typed it in, incase i change it)
 
You understood perfectly. Sorry about my long explenation, its kinda hard to explain and I didnt know how to type it.

only thing is, when you interrurpted what I said. I have a "Label" instead of textbox that switches from Username to password. But like that matters you helped me wonderfully.


Thanks man, and i"m glad I"m not the only young guy out there.

Ill be checking out your webpage, looks good!

Thanks again budd - I"ll try the code
 
Oh and the

application.DoEvents()
System.Threading.Thread.Sleep

is a way I found to delay the program wrather then delay the entire system. If you get what Im saying...

Instead of pausing the entire machine, I want to just pause the thread...
 
Application.DoEvents() allows all pending Windows messages to be processed, so that tight-loops dont cause the system to hang.
 
Application.DoEvents() lets the OS handle its messages, very useful in loops. If you have a loop that does a lot of things the OS can be stuck in the loop and not processing other messages which can cause it to freeze.
[edit]:) beat me[/edit]
 
He means I snuck in my reply just seconds before he could get his in. :p
 
Back
Top