0% found this document useful (0 votes)
55 views1 page

Exercise 17

This code defines a form with a button click event that generates three random numbers between 1-3 and displays them on labels. It checks if all numbers match and if so, adds bonus tokens to the starting token value of 100 - adding 4 tokens if all are 1, 8 tokens if all are 2, or 12 tokens if all are 3, displaying the amount won in a message box.

Uploaded by

api-308657631
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views1 page

Exercise 17

This code defines a form with a button click event that generates three random numbers between 1-3 and displays them on labels. It checks if all numbers match and if so, adds bonus tokens to the starting token value of 100 - adding 4 tokens if all are 1, 8 tokens if all are 2, or 12 tokens if all are 3, displaying the amount won in a message box.

Uploaded by

api-308657631
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Public Class Form1

Dim token As Integer = 100


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
token = token - 1
Randomize()
Dim num1 As Integer = Int(3 * Rnd()) + 1
Dim num2 As Integer = Int(3 * Rnd()) + 1
Dim num3 As Integer = Int(3 * Rnd()) + 1
Label1.Text = num1
Label2.Text = num2
Label3.Text = num3
If num1 = 1 And num2 = 1 And num3 = 1 Then
token = token + 4
MessageBox.Show("You got 4 tokens!")
End If

If num1 = 2 And num2 = 2 And num3 = 2 Then


token = token + 8
MessageBox.Show("You got 8 tokens!")
End If

If num1 = 3 And num2 = 3 And num3 = 3 Then


token = token + 12
MessageBox.Show("You got 12 tokens!")
End If
End Sub
End Class

You might also like