Old 10-29-2009, 12:33 AM   #1 (permalink)
Game Journalist
 
Abubakr's Avatar
 
Join Date: Feb 2008
Location: Mississauga, Ontario, Canada
Posts: 4,266
Reputation: 36
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?
__________________




Abubakr is offline   Reply With Quote
Old 10-29-2009, 01:06 AM   #2 (permalink)
Banned
 
hobosexual's Avatar
 
Join Date: May 2006
Location: Stranger In A Strange Land
Posts: 3,913
Reputation: 134
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.
hobosexual is offline   Reply With Quote
Old 10-29-2009, 01:51 AM   #3 (permalink)
Game Journalist
 
Abubakr's Avatar
 
Join Date: Feb 2008
Location: Mississauga, Ontario, Canada
Posts: 4,266
Reputation: 36
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
__________________




Abubakr is offline   Reply With Quote
Old 10-29-2009, 01:52 AM   #4 (permalink)
Banned
 
hobosexual's Avatar
 
Join Date: May 2006
Location: Stranger In A Strange Land
Posts: 3,913
Reputation: 134
Default

Yeah I'll do my best.

Just gonna go take a quick shower then I'll look at it.
hobosexual is offline   Reply With Quote
Old 10-29-2009, 01:54 AM   #5 (permalink)
Game Journalist
 
Abubakr's Avatar
 
Join Date: Feb 2008
Location: Mississauga, Ontario, Canada
Posts: 4,266
Reputation: 36
Default

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




Abubakr is offline   Reply With Quote
Old 11-04-2009, 08:07 PM   #6 (permalink)
Banned
 
Join Date: May 2009
Location: USA. Unified Sarcastic Anal... something...
Posts: 591
Reputation: 9
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   Reply With Quote
Old 11-05-2009, 01:46 AM   #7 (permalink)
Game Journalist
 
Abubakr's Avatar
 
Join Date: Feb 2008
Location: Mississauga, Ontario, Canada
Posts: 4,266
Reputation: 36
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.
__________________




Abubakr is offline   Reply With Quote
Old 11-05-2009, 03:09 AM   #8 (permalink)
Banned
 
Join Date: May 2009
Location: USA. Unified Sarcastic Anal... something...
Posts: 591
Reputation: 9
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   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 On



All times are GMT. The time now is 09:46 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.6.0
OnRPG, Copyright ©2003-2011, Game Entertainment Enterprises