bstobbe

Slot Machine

Apr 3rd, 2017
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Public Class Form1
  2.     Dim left As Integer
  3.     Dim center As Integer
  4.     Dim right As Integer
  5.  
  6.     Dim leftImage As Integer
  7.     Dim centerImage As Integer
  8.     Dim rightImage As Integer
  9.  
  10.     Dim slotleft As Integer
  11.     Dim slotcenter As Integer
  12.     Dim slotright As Integer
  13.  
  14.     Dim timer As Integer = 15
  15.  
  16.     Dim winnings As Integer
  17.     Dim bet As Integer
  18.     Dim totalwinnings As Integer = 1000
  19.  
  20.  
  21.     Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  22.  
  23.         totalwinnings = totalwinnings - bet
  24.  
  25.  
  26.         Randomize()
  27.  
  28.         left = (Rnd() * 5) + 1
  29.         center = (Rnd() * 5) + 1
  30.         right = (Rnd() * 5) + 1
  31.  
  32.         Timer1.Enabled = True
  33.  
  34.         If left = 1 Then
  35.             PictureBox1.BackgroundImage = My.Resources.slotsbell
  36.         ElseIf left = 2 Then
  37.             PictureBox1.BackgroundImage = My.Resources.slotscherry
  38.         ElseIf left = 3 Then
  39.             PictureBox1.BackgroundImage = My.Resources.slotsseven
  40.         ElseIf left = 4 Then
  41.             PictureBox1.BackgroundImage = My.Resources.slotswatermelon
  42.         ElseIf left = 5 Then
  43.             PictureBox1.BackgroundImage = My.Resources.Slot_Grapes
  44.  
  45.         End If
  46.  
  47.         If center = 1 Then
  48.             PictureBox2.BackgroundImage = My.Resources.slotsbell
  49.         ElseIf center = 2 Then
  50.             PictureBox2.BackgroundImage = My.Resources.slotscherry
  51.         ElseIf center = 3 Then
  52.             PictureBox2.BackgroundImage = My.Resources.slotsseven
  53.         ElseIf center = 4 Then
  54.             PictureBox2.BackgroundImage = My.Resources.slotswatermelon
  55.         ElseIf center = 5 Then
  56.             PictureBox2.BackgroundImage = My.Resources.Slot_Grapes
  57.  
  58.         End If
  59.  
  60.         If right = 1 Then
  61.             PictureBox3.BackgroundImage = My.Resources.slotsbell
  62.         ElseIf right = 2 Then
  63.             PictureBox3.BackgroundImage = My.Resources.slotscherry
  64.         ElseIf right = 3 Then
  65.             PictureBox3.BackgroundImage = My.Resources.slotsseven
  66.         ElseIf right = 4 Then
  67.             PictureBox3.BackgroundImage = My.Resources.slotswatermelon
  68.         ElseIf right = 5 Then
  69.             PictureBox3.BackgroundImage = My.Resources.Slot_Grapes
  70.  
  71.         End If
  72.         Label2.Text = totalwinnings
  73.  
  74.  
  75.     End Sub
  76.  
  77.     Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
  78.  
  79.  
  80.  
  81.  
  82.  
  83.         timer = timer - 1
  84.  
  85.  
  86.         If timer Mod 5 = 1 Then
  87.             PictureBox1.BackgroundImage = My.Resources.slotsbell
  88.         ElseIf timer Mod 5 = 2 Then
  89.             PictureBox1.BackgroundImage = My.Resources.slotscherry
  90.         ElseIf timer Mod 5 = 3 Then
  91.             PictureBox1.BackgroundImage = My.Resources.slotsseven
  92.         ElseIf timer Mod 5 = 4 Then
  93.             PictureBox1.BackgroundImage = My.Resources.slotswatermelon
  94.         ElseIf timer Mod 5 = 0 Then
  95.             PictureBox1.BackgroundImage = My.Resources.Slot_Grapes
  96.  
  97.         End If
  98.  
  99.         If timer Mod 5 = 4 Then
  100.             PictureBox2.BackgroundImage = My.Resources.slotsbell
  101.         ElseIf timer Mod 5 = 3 Then
  102.             PictureBox2.BackgroundImage = My.Resources.slotscherry
  103.         ElseIf timer Mod 5 = 2 Then
  104.             PictureBox2.BackgroundImage = My.Resources.slotsseven
  105.         ElseIf timer Mod 5 = 1 Then
  106.             PictureBox2.BackgroundImage = My.Resources.slotswatermelon
  107.         ElseIf timer Mod 5 = 0 Then
  108.             PictureBox2.BackgroundImage = My.Resources.Slot_Grapes
  109.  
  110.         End If
  111.  
  112.         If timer Mod 5 = 0 Then
  113.             PictureBox3.BackgroundImage = My.Resources.slotsbell
  114.         ElseIf timer Mod 5 = 2 Then
  115.             PictureBox3.BackgroundImage = My.Resources.slotscherry
  116.         ElseIf timer Mod 5 = 4 Then
  117.             PictureBox3.BackgroundImage = My.Resources.slotsseven
  118.         ElseIf timer Mod 5 = 3 Then
  119.             PictureBox3.BackgroundImage = My.Resources.slotswatermelon
  120.         ElseIf timer Mod 5 = 1 Then
  121.             PictureBox3.BackgroundImage = My.Resources.Slot_Grapes
  122.  
  123.  
  124.         End If
  125.         If timer <= 0 Then
  126.             Timer1.Enabled = False
  127.             timer = 15
  128.  
  129.  
  130.  
  131.             slotleft = (Rnd() * 5) + 1
  132.             slotcenter = (Rnd() * 5) + 1
  133.             slotright = (Rnd() * 5) + 1
  134.  
  135.  
  136.             If slotleft = 1 Then
  137.                 PictureBox1.BackgroundImage = My.Resources.slotsbell
  138.             ElseIf slotleft = 2 Then
  139.                 PictureBox1.BackgroundImage = My.Resources.slotscherry
  140.             ElseIf slotleft = 3 Then
  141.                 PictureBox1.BackgroundImage = My.Resources.slotsseven
  142.             ElseIf slotleft = 4 Then
  143.                 PictureBox1.BackgroundImage = My.Resources.slotswatermelon
  144.             ElseIf slotleft = 5 Then
  145.                 PictureBox1.BackgroundImage = My.Resources.Slot_Grapes
  146.  
  147.             End If
  148.  
  149.             If slotcenter = 1 Then
  150.                 PictureBox2.BackgroundImage = My.Resources.slotsbell
  151.             ElseIf slotcenter = 2 Then
  152.                 PictureBox2.BackgroundImage = My.Resources.slotscherry
  153.             ElseIf slotcenter = 3 Then
  154.                 PictureBox2.BackgroundImage = My.Resources.slotsseven
  155.             ElseIf slotcenter = 4 Then
  156.                 PictureBox2.BackgroundImage = My.Resources.slotswatermelon
  157.             ElseIf slotcenter = 5 Then
  158.                 PictureBox2.BackgroundImage = My.Resources.Slot_Grapes
  159.  
  160.             End If
  161.  
  162.             If slotright = 1 Then
  163.                 PictureBox3.BackgroundImage = My.Resources.slotsbell
  164.             ElseIf slotright = 2 Then
  165.                 PictureBox3.BackgroundImage = My.Resources.slotscherry
  166.             ElseIf slotright = 3 Then
  167.                 PictureBox3.BackgroundImage = My.Resources.slotsseven
  168.             ElseIf slotright = 4 Then
  169.                 PictureBox3.BackgroundImage = My.Resources.slotswatermelon
  170.             ElseIf slotright = 5 Then
  171.                 PictureBox3.BackgroundImage = My.Resources.Slot_Grapes
  172.  
  173.             End If
  174.  
  175.  
  176.  
  177.             If slotright = 1 And slotcenter = 1 And slotleft = 1 Then
  178.                 totalwinnings = totalwinnings + bet + (bet * 2)
  179.             ElseIf slotleft = 2 And slotcenter = 2 And slotright = 2 Then
  180.                 totalwinnings = totalwinnings + bet + (bet * 5)
  181.             ElseIf slotleft = 3 And slotcenter = 3 And slotright = 3 Then
  182.                 totalwinnings = totalwinnings + bet + (bet * 10)
  183.             ElseIf slotleft = 4 And slotcenter = 4 And slotright = 4 Then
  184.                 totalwinnings = totalwinnings + bet + (bet * 20)
  185.             ElseIf slotleft = 5 And slotcenter = 5 And slotright = 5 Then
  186.                 totalwinnings = totalwinnings + bet + (bet * 100)
  187.             End If
  188.         End If
  189.  
  190.         Label2.Text = totalwinnings
  191.         If totalwinnings <= 0 Then
  192.             MessageBox.Show("YOU LOSE")
  193.             Application.Exit()
  194.         End If
  195.  
  196.     End Sub
  197.  
  198.     Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  199.         bet = bet + 10
  200.         Label3.Text = bet
  201.  
  202.  
  203.  
  204.     End Sub
  205.  
  206.     Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
  207.         bet = bet - 10
  208.         Label3.Text = bet
  209.     End Sub
  210.  
  211.     Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  212.         MessageBox.Show("Rules!" & vbCrLf & "Add your bet as high as you would like, but you will only win if you get 3 of a kind" & vbCrLf & "Best of Luck and try not to lose all of your money")
  213.     End Sub
  214.  
  215.     Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
  216.         MessageBox.Show("Odds" & vbCrLf & "Bell= x2" & vbCrLf & "Cherry= x5" & vbCrLf & "Seven= x10" & vbCrLf & "Watermelon= x20" & vbCrLf & "Grape= x100")
  217.     End Sub
  218. End Class
Add Comment
Please, Sign In to add comment