How to make a Number Guesser Game!
Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
4 posts
Page 1 of 1
Level = ★★★★☆
Rated ★★★★☆, user must: Have must around with Visual Basic 2010, and you know how to code on your own.
Tutorial time!
Ok, today I will show everyone how to make a simple number guessing game!
You will need:
![Image]()
Purple = TextBox | Name = Textbox
Red = Labels | Label1.Name = LabelNumGuess | Label2.Name = LabelHighLow | Label3.Name = Label3
Blue = RadioButtons | RadioButton1.Name = RadioButton10 | RadioButton2.Name = RadioButton100 | RadioButton3.Name = RadioButton1000
Black = Buttons | keep the names
Ok, now time for the text!
Radio Buttons
![Image]()
On the right:
Rated ★★★★☆, user must: Have must around with Visual Basic 2010, and you know how to code on your own.
Tutorial time!
Ok, today I will show everyone how to make a simple number guessing game!
You will need:
- 3 labels
2 buttons
1 group box
3 radiobuttons
1 textbox

Purple = TextBox | Name = Textbox
Red = Labels | Label1.Name = LabelNumGuess | Label2.Name = LabelHighLow | Label3.Name = Label3
Blue = RadioButtons | RadioButton1.Name = RadioButton10 | RadioButton2.Name = RadioButton100 | RadioButton3.Name = RadioButton1000
Black = Buttons | keep the names
Ok, now time for the text!
Radio Buttons
- RadioButton10.Text = "Game 1 - 10"
RadioButton100.Text = "Game 1 - 100"
RadioButton1000.Text = "Game 1 - 1000"
- Button1.Text = "Submit"
Button2.Text = "Start Game"
- LabelHighLow.Text = "Higher or Lower"
LabelNumGuess.Text = "Number Of Guesses: *Yea there is a space!!*"
Label3.Text = "Enter a number:"
- GroupBox1.Text = "Select A Game!"

On the right:
- The radiobuttons (INSIDE the group box)
Button2 (the start game button)
- Labels
TextBox
Button1
Code: Select all
If you have problems PM me, or just leave a comment, and I or another coder will help you out! Have fun codersPublic Class Form1
Dim ComputerNumber As Integer
Dim Count As Integer
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Count = 0
GroupBox1.Enabled = False
Button2.Enabled = False
Button1.Enabled = True
TextBoxGuess.Enabled = True
LabelNumGuess.Text = "Number Of Guesses: " + Str(Count)
LabelHighLow.Text = ""
TextBoxGuess.Focus()
TextBoxGuess.Clear()
GetNumber()
End Sub
Private Sub GetNumber()
Randomize()
If RadioButton10.Checked = True Then
ComputerNumber = Rnd() * 9 + 1
ElseIf RadioButton100.Checked = True Then
ComputerNumber = Rnd() * 99 + 1
ElseIf RadioButton1000.Checked = True Then
ComputerNumber = Rnd() * 999 + 1
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBoxGuess.Text <> "" Then
Try
If Integer.Parse(TextBoxGuess.Text) = ComputerNumber Then
CorrectGuess()
Else
NotCorrectGuess()
End If
Catch ex As Exception
TextBoxGuess.Clear()
TextBoxGuess.Focus()
MsgBox(ex.Message)
End Try
End If
End Sub
Private Sub CorrectGuess()
Count += 1
LabelNumGuess.Text = "Number Of Guesses: " + Str(Count)
GroupBox1.Enabled = True
Button2.Enabled = True
Button1.Enabled = False
TextBoxGuess.Enabled = False
MsgBox("You guessed my number! You guessed it in: " + Str(Count) + " guesses! YAY!!", MsgBoxStyle.Exclamation, "Congratulations!")
End Sub
Private Sub NotCorrectGuess()
Count += 1
LabelNumGuess.Text = "Number Of Guesses: " + Str(Count)
If Integer.Parse(TextBoxGuess.Text) < ComputerNumber Then
LabelHighLow.Text = "Higher!"
Else
LabelHighLow.Text = "Lower!"
End If
TextBoxGuess.Clear()
TextBoxGuess.Focus()
End Sub
End Class
Nice tutorial!!! cooll;
Might help some beginners!!

Might help some beginners!!
Instead of LOL use this -
LSIBMHBIWFETALOL
Which means -
Laughing silently in between my head because it wasn't funny enough to actually laugh out loud!
LSIBMHBIWFETALOL
Which means -
Laughing silently in between my head because it wasn't funny enough to actually laugh out loud!
CoderBoy1201 wrote:Nice tutorial!!! cooll;Thank you! I appreciate the nice comments![]()
Might help some beginners!!
4 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023