Jump to content

Number Guessing Game, NEED HELP!!!!

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
4 replies to this topic

#1
Clawbo

Clawbo

    Newbie

  • Members
  • Pip
  • 7 posts
Hi people, I'm new here, I'm 13 and I would really want to learn programming, C, C++ and Visual Basic. I need help with a game of mine, here's the code (Parts of it are Croatian, broj = number, točan_broj = Correct_number)

Public Class Form1


    Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click

        Me.Close()

    End Sub


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click


        Dim broj As Single

        Dim točan_broj As Single


        točan_broj = Rnd(10)


        broj = TextBox1.Text


        Do Until broj = točan_broj


            If broj < točan_broj Then Label2.Text = "Moj broj je veći od tvoga!"

            If broj > točan_broj Then Label2.Text = "Moj broj je manji od tvoga!"




            If broj = točan_broj Then


                Label1.Text = "Točno, točan broj je " & točan_broj

                TextBox2.Text = točan_broj

                Točno.Show()


            Else


                Label2.Text = "Krivo Bre!!"


            End If


        Loop


    End Sub


End Class

When I run it and type the first number (my guess) the app freezes up, without any obvious reason. What am I doing wrong here?

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
You never update broj inside your Do Until loop, so it loops forever.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
Clawbo

Clawbo

    Newbie

  • Members
  • Pip
  • 7 posts
What should I do then?

#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Why do you have the Do Until loop? Aren't you pressing a button after each guess?
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#5
Clawbo

Clawbo

    Newbie

  • Members
  • Pip
  • 7 posts
Never mind, got it solved now, thanks for your help!