Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (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 by xcorp

X-Corp

Take a hit

Posted

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)

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

Posted

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

X-Corp

Take a hit

Posted

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...

X-Corp

Take a hit

  • *Experts*
Posted
Application.DoEvents() allows all pending Windows messages to be processed, so that tight-loops don't cause the system to hang.
  • *Experts*
Posted

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]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...