Advertisement
Guest User

3242526272

a guest
Dec 11th, 2011
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 3.88 KB | None | 0 0
  1.  
  2. '.-----------------------------------------------------------.
  3. '|README                                                     |
  4. '|******                                                     |
  5. '|You must change the paths in sub "form_load" to match the  |
  6. '|location of your dice images as the drive letter will      |
  7. '|probably be different!                                     |
  8. '.-----------------------------------------------------------.
  9.  
  10. Public Class Form1
  11.  
  12.     Dim path_image(5) As String 'array stroring oaths of dice images
  13.     Dim rndnum(11) As Integer 'array stroring 12 rnd numbers
  14.     Dim total(2) As Integer 'array storing totals for the 3 dice combos
  15.  
  16.     Private Sub bt_start_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_start.Click
  17.         'clears totals
  18.         total(0) = 0
  19.         total(1) = 0
  20.         total(2) = 0
  21.         'clears totals
  22.         'dice combo #1
  23.         For i = 0 To 3
  24.             rndnum(i) = Int((6 * Rnd()) + 1)
  25.             If rndnum(i) = 3 Then
  26.                 total(0) = total(0) + 2
  27.             ElseIf rndnum(i) = 5 Then
  28.                 total(0) = total(0) + 4
  29.             End If
  30.         Next
  31.         'dice combo #1
  32.         'dice combo #2
  33.         For i = 4 To 7
  34.             rndnum(i) = Int((6 * Rnd()) + 1)
  35.             If rndnum(i) = 3 Then
  36.                 total(1) = total(1) + 2
  37.             ElseIf rndnum(i) = 5 Then
  38.                 total(1) = total(1) + 4
  39.             End If
  40.  
  41.         Next
  42.         'dice combo #2
  43.         'dice combo #3
  44.         For i = 8 To 11
  45.             rndnum(i) = Int((6 * Rnd()) + 1)
  46.             If rndnum(i) = 3 Then
  47.                 total(2) = total(2) + 2
  48.             ElseIf rndnum(i) = 5 Then
  49.                 total(2) = total(2) + 4
  50.             End If
  51.         Next
  52.         'dice combo #3
  53.         'Assignes dice image to imageboxes@form
  54.         pb_11.Image = Image.FromFile(path_image(rndnum(0) - 1))
  55.         pb_12.Image = Image.FromFile(path_image(rndnum(1) - 1))
  56.         pb_13.Image = Image.FromFile(path_image(rndnum(2) - 1))
  57.         pb_14.Image = Image.FromFile(path_image(rndnum(3) - 1))
  58.         pb_21.Image = Image.FromFile(path_image(rndnum(4) - 1))
  59.         pb_22.Image = Image.FromFile(path_image(rndnum(5) - 1))
  60.         pb_23.Image = Image.FromFile(path_image(rndnum(6) - 1))
  61.         pb_24.Image = Image.FromFile(path_image(rndnum(7) - 1))
  62.         pb_31.Image = Image.FromFile(path_image(rndnum(8) - 1))
  63.         pb_32.Image = Image.FromFile(path_image(rndnum(9) - 1))
  64.         pb_33.Image = Image.FromFile(path_image(rndnum(10) - 1))
  65.         pb_34.Image = Image.FromFile(path_image(rndnum(11) - 1))
  66.         'Assignes dice image to imageboxes@form
  67.         'fills textbox_totals@form
  68.         tb_total1.Text = total(0)
  69.         tb_total2.Text = total(1)
  70.         'fills total boxes@form
  71.  
  72.     End Sub
  73.  
  74.  
  75.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  76.         'Assignes paths of dice images to array
  77.         path_image(0) = "G:\school\Computing\Programming\Rings_around_the_rose\Dice\1.png"
  78.         path_image(1) = "G:\school\Computing\Programming\Rings_around_the_rose\Dice\2.png"
  79.         path_image(2) = "G:\school\Computing\Programming\Rings_around_the_rose\Dice\3.png"
  80.         path_image(3) = "G:\school\Computing\Programming\Rings_around_the_rose\Dice\4.png"
  81.         path_image(4) = "G:\school\Computing\Programming\Rings_around_the_rose\Dice\5.png"
  82.         path_image(5) = "G:\school\Computing\Programming\Rings_around_the_rose\Dice\6.png"
  83.         'Assignes paths of dice images to array
  84.     End Sub
  85.  
  86.     Private Sub bt_check_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_check.Click
  87.         'checks answer
  88.         If tb_total3.Text = total(2) Then
  89.             MsgBox("CORRECT!")
  90.         Else
  91.             MsgBox("WRONG!")
  92.         End If
  93.         'checks answer
  94.     End Sub
  95. End Class
  96.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement