xcorp Posted August 5, 2003 Posted August 5, 2003 (edited) Hey I'm 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 i'm using all my brain power here :p I'm not sure if your with me here but what I have so for is like.. well I'm on a dif computer so I'm 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 isn't 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, it's not EXACTLY like i have in my program. I can't 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. I'm 13 years old.... And Not the smartest one in the box Any help would be appriciated!! Edited August 5, 2003 by xcorp Quote X-Corp Take a hit
ThePentiumGuy Posted August 5, 2003 Posted August 5, 2003 hey, listen, here's 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 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) Quote My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!) vbprogramming.8k.com My Project (Need VB.NET Programmers) http://workspaces.gotdotnet.com/ResolutionRPG
ThePentiumGuy Posted August 5, 2003 Posted August 5, 2003 by the way, can u clarify what u said, i really dont understand it.. but i hope i got your point right Quote My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!) vbprogramming.8k.com My Project (Need VB.NET Programmers) http://workspaces.gotdotnet.com/ResolutionRPG
xcorp Posted August 5, 2003 Author Posted August 5, 2003 You understood perfectly. Sorry about my long explenation, it's kinda hard to explain and I didn't 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. I'll be checking out your webpage, looks good! Thanks again budd - I"ll try the code Quote X-Corp Take a hit
xcorp Posted August 5, 2003 Author Posted August 5, 2003 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 I'm saying... Instead of pausing the entire machine, I want to just pause the thread... Quote X-Corp Take a hit
ThePentiumGuy Posted August 7, 2003 Posted August 7, 2003 yeah, i get that... although i dont know how your program would delay the entire system. I got a question for you tho, what does Application.DoEvents() do? Quote My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!) vbprogramming.8k.com My Project (Need VB.NET Programmers) http://workspaces.gotdotnet.com/ResolutionRPG
*Experts* Volte Posted August 7, 2003 *Experts* Posted August 7, 2003 Application.DoEvents() allows all pending Windows messages to be processed, so that tight-loops don't cause the system to hang. Quote
*Experts* mutant Posted August 7, 2003 *Experts* Posted August 7, 2003 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] Quote
ThePentiumGuy Posted August 13, 2003 Posted August 13, 2003 [edit]:) beat me[/edit] [/b] "Beat me"? anyway thanks for ur help Quote My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!) vbprogramming.8k.com My Project (Need VB.NET Programmers) http://workspaces.gotdotnet.com/ResolutionRPG
*Experts* Volte Posted August 13, 2003 *Experts* Posted August 13, 2003 He means I snuck in my reply just seconds before he could get his in. :p Quote
ThePentiumGuy Posted August 13, 2003 Posted August 13, 2003 oh lol alright Quote My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!) vbprogramming.8k.com My Project (Need VB.NET Programmers) http://workspaces.gotdotnet.com/ResolutionRPG
xcorp Posted August 13, 2003 Author Posted August 13, 2003 ITS A WAR OUT HERE!! ITS A WAR Quote X-Corp Take a hit
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.