0% found this document useful (0 votes)
26 views

Exercise 9

The document describes a program that simulates a gambling game where the user starts with 1000 points. They can enter a risk amount and click one of two buttons - Button1 pays out if a random number between 1-13 is 8 or higher, Button2 pays out if the number is 8 or lower. After each round the user's points are updated and displayed based on whether they won or lost.

Uploaded by

api-308657631
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

Exercise 9

The document describes a program that simulates a gambling game where the user starts with 1000 points. They can enter a risk amount and click one of two buttons - Button1 pays out if a random number between 1-13 is 8 or higher, Button2 pays out if the number is 8 or lower. After each round the user's points are updated and displayed based on whether they won or lost.

Uploaded by

api-308657631
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Public Class Form1

Dim points As Integer = 1000


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
Randomize()
Dim risk As Integer = TextBox1.Text
Dim num As Integer = Int(Rnd() * 13) + 1
If num >= 8 Then
Label2.Text = "You win! The number was " + num.ToString
points = points + risk
Label3.Text = "Total points = " + points.ToString
Else
Label2.Text = "You loose! The number was " + num.ToString
points = points - risk
Label3.Text = "Total points = " + points.ToString
End If
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button2.Click
Randomize()
Dim risk As Integer = TextBox1.Text
Dim num As Integer = Int(Rnd() * 13) + 1
If num <= 8 Then
Label2.Text = "You win! The number was " + num.ToString
points = points + risk
Label3.Text = "Total points = " + points.ToString
Else
Label2.Text = "You loose! The number was " + num.ToString
points = points - risk
Label3.Text = "Total points = " + points.ToString
End If
End Sub
End Class

You might also like