Jump to content

Help with button game

- - - - -

  • Please log in to reply
4 replies to this topic

#1
Aire-DaZ

Aire-DaZ

    Newbie

  • Members
  • Pip
  • 3 posts
Hey there!!!!
Well im somehow new to visual basic but I know some basic codes..So now i want to make something like a "Dont press the red button" game. With every click of the button the text of it will change but everytime i press it, it changes to the last text i wrote
Can anyone help me? I performed a searh but couldn't find anything :[


#2
Revolt

Revolt

    Programmer

  • Members
  • PipPipPip
  • 99 posts
Well, in order for us to help you, you have to provide the part of the source code where you do this text change you are talking about. Otherwise there's just no way for us to know how to solve your problem!

#3
Aire-DaZ

Aire-DaZ

    Newbie

  • Members
  • Pip
  • 3 posts
 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click)

        If Button1.Text = ("1") Then

            Button1.Text = ("2")

            If Button1.Text = ("2") Then

                Button1.Text = ("3")

            End If

        End If

    End Sub
every time i click it i just get 3 and not 2 and then 3 im newb :P help pls?

#4
Revolt

Revolt

    Programmer

  • Members
  • PipPipPip
  • 99 posts
The problem is that you put the second if inside the first one. That way, you can never enter the second if because that would mean that you are inside the first one and that Text = "2".

What you really want is

If Button1.Text = "1" Then

   Button1.Text = "2"

ElseIf Button1.Text = "2" Then

   Button1.Text = "3"

Else

   Button1.Text = "1"

End If


#5
Aire-DaZ

Aire-DaZ

    Newbie

  • Members
  • Pip
  • 3 posts
aha thank you it worked
sorry for my stupidity




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users