Old 10-28-2009, 11:33 PM   #1 (permalink)
Kohaku
 
Abubakr's Avatar
 
Join Date: Feb 2008
Location: Mississauga, Ontario, Canada
Posts: 3,075
Abubakr is on a distinguished road
Default Visual Basic

This is a question for all of you programmers. So I have to make a program which can do various things for school. I have a plan in mind, but don't know how to execute it.

I will only explain the part where I am having trouble. I have a label which changes when you press a button. This is all good, but what I want is to change the label to different things when you click many times.

For example:

1 Click: Label will say Hi
2 Clicks: Label will say I'm fine
Ect.

What I am having trouble with is that the whole code executes in one click, making the end message come in one click.

Here is my idea, which doesn't work.

Code:
Private Sub btnHi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHi.Click
        lblMessage.Text = "Hello!"
        btnHi.Text = "How are you?"
        If btnHi.Text = "How are you?" Then
            lblMessage.Text = "I'm fine, you?"
        End If
    End Sub
So whats happening is that it quickly goes through it all, as after the button changes to say How are you? the program recognizes it and changes the label as well.

What I want is that the button says How are you? and then the user has to click on it to make the next message appear.

How can I do this?
__________________


Thanks to my brother.


Abubakr is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-29-2009, 12:06 AM   #2 (permalink)
Chrono's Crony
 
hobosexual's Avatar
 
Join Date: May 2006
Location: ¯\(°_O)/¯
Posts: 3,366
hobosexual will become famous soon enough
Default

I'm dling VB right now since I don't have it installed on my laptop.

I'm gonna try something and just copy/paste the code here if it works cause I suck *** at explaining stuff.

I'm not exactly the greatest at this right now though, come back and ask me in several years when I have my masters and I'll def be able to explain it to you though lol.
__________________

All night I'll hunt for you
Let me show you what I mean...
hobosexual is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-29-2009, 12:51 AM   #3 (permalink)
Kohaku
 
Abubakr's Avatar
 
Join Date: Feb 2008
Location: Mississauga, Ontario, Canada
Posts: 3,075
Abubakr is on a distinguished road
Default

Thanks.

See if you can get it before 10PM as then I have to sleep. We will be coding tomorrow so I don't want to do it my long way that I had originally planned.

Which was, click the button it disappears and a new one appears with the new dialog and action.

That way isn't the best. xD
__________________


Thanks to my brother.


Abubakr is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-29-2009, 12:52 AM   #4 (permalink)
Chrono's Crony
 
hobosexual's Avatar
 
Join Date: May 2006
Location: ¯\(°_O)/¯
Posts: 3,366
hobosexual will become famous soon enough
Default

Yeah I'll do my best.

Just gonna go take a quick shower then I'll look at it.
__________________

All night I'll hunt for you
Let me show you what I mean...
hobosexual is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-29-2009, 12:54 AM   #5 (permalink)
Kohaku
 
Abubakr's Avatar
 
Join Date: Feb 2008
Location: Mississauga, Ontario, Canada
Posts: 3,075
Abubakr is on a distinguished road
Default

If you are busy don't worry about it. I'll figure it out tomorrow then.
__________________


Thanks to my brother.


Abubakr is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 11-04-2009, 08:07 PM   #6 (permalink)
Raider of Empty Tombs
 
Join Date: May 2009
Location: USA. Unified Sarcastic Anal... something...
Posts: 357
timeb0mb is on a distinguished road
Default

Code:
    Private Sub Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button.Click
        If Button.Text = "Hello." Then
            Label.Text = "Hi!"
            Button.Text = "How are you?"
        ElseIf Button.Text = "How are you?" Then
            Label.Text = "I'm fine."
            Button.Text = "I'm great!"
        ElseIf Button.Text = "I'm great!" Then
            Label.Text = "That's good to hear!"
            Button.Dispose()
        End If

    End Sub
This is how to do it
Button.Dispose makes the button invisible after your conversation is over ^^
If you need any other help with VB.Net, feel free to ask.
__________________
timeb0mb is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 11-05-2009, 01:46 AM   #7 (permalink)
Kohaku
 
Abubakr's Avatar
 
Join Date: Feb 2008
Location: Mississauga, Ontario, Canada
Posts: 3,075
Abubakr is on a distinguished road
Default

Thank you. I had tried that before but without the else so maybe that is why it didn't work. I'll try it out soon and let you know.
__________________


Thanks to my brother.


Abubakr is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 11-05-2009, 03:09 AM   #8 (permalink)
Raider of Empty Tombs
 
Join Date: May 2009
Location: USA. Unified Sarcastic Anal... something...
Posts: 357
timeb0mb is on a distinguished road
Default

I tested this personally and it worked perfectly, so I hope it does the same for you.
The problem with not using else is, after the first if is done, the sub checks the second if. Since the first if is done and changed the button name, the second if will continue without them clicking it again. Kinda confusing, I know. By using if, it only checks ONE of them per click, instead of doing one by one by one per click.
__________________
timeb0mb is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump


All times are GMT. The time now is 11:27 AM.


Powered by vBulletin® Version 3.7.5
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
Onrpg, Copyright ©2003-2008, Spil Games