Your SlideShare is downloading. ×
Laboratory activity 3 b3
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Laboratory activity 3 b3

385
views

Published on


1 Comment
1 Like
Statistics
Notes
No Downloads
Views
Total Views
385
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
22
Comments
1
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Laboratory Activity 3 (Batch 3) Roll Dice Program Public Class Form1 Private dice1 As Integer Private dice2 As Integer Private two, three, four, five, six, seven, eight, nine, ten, eleven, twelve As Integer Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim objRN As Random = New Random dice1 = objRN.Next(1, 7) dice2 = objRN.Next(1, 7) Label1.Text = dice1 Label3.Text = dice2 CountDice(dice1, dice2) End Sub Sub CountDice(ByVal x As Integer, ByVal y As Integer) If (x + y) = 2 Then two = two + 1
  • 2. ElseIf (x + y) = 3 Then three = three + 1 ElseIf (x + y) = 4 Then four = four + 1 ElseIf (x + y) = 5 Then five = five + 1 ElseIf (x + y) = 6 Then six = six + 1 ElseIf (x + y) = 7 Then seven = seven + 1 ElseIf (x + y) = 8 Then eight = eight + 1 ElseIf (x + y) = 9 Then nine = nine + 1 ElseIf (x + y) = 10 Then ten = ten + 1 ElseIf (x + y) = 11 Then eleven = eleven + 1 Else twelve = twelve + 1 End If End Sub Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click ListBox1.Items.Clear() ListBox1.Items.Add(" Value Count") ListBox1.Items.Add(" ---------- -----------") ListBox1.Items.Add(" ") ListBox1.Items.Add(" 2 " & two) ListBox1.Items.Add(" 3 " & three) ListBox1.Items.Add(" 4 " & four) ListBox1.Items.Add(" 5 " & five) ListBox1.Items.Add(" 6 " & six) ListBox1.Items.Add(" 7 " & seven) ListBox1.Items.Add(" 8 " & eight) ListBox1.Items.Add(" 9 " & nine) ListBox1.Items.Add(" 10 " & ten) ListBox1.Items.Add(" 11 " & eleven) ListBox1.Items.Add(" 12 " & twelve) End Sub End Class

×