Advertisement
Chong_IntroCS

slotmachine2

Mar 29th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Public Class Form1
  2.  
  3.     Dim time As Integer = 25
  4.     Dim time2 As Integer = 47
  5.     Dim time3 As Integer = 75
  6.     Dim picnumber As String
  7.     Dim picnumber2 As String
  8.     Dim picnumber3 As String
  9.     Dim totalcash As Integer = 1000
  10.     Dim betmoneymax As Integer = 0
  11.     Dim betmoney As Integer = 0
  12.  
  13.  
  14.  
  15.  
  16.     ' in order to play, total cash has to be greater than zero. cant bet more than they have.
  17.    ' before spin, check how much cash there is, cant bet more than you have.
  18.  
  19.     Private Sub Button1_Click(sender As Object, e As EventArgs)
  20.     End Sub
  21.  
  22.  
  23.     Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
  24.         Randomize()
  25.  
  26.  
  27.         time = time - 1
  28.         Label1.Text = time
  29.         'picnumber = Str((Int(Rnd() * 6) + 1))
  30.        'Label2.Text = picnumber
  31.  
  32.  
  33.         If time Mod 6 = " 0" Then
  34.             PictureBox2.BackgroundImage = My.Resources.icon1
  35.         ElseIf time Mod 6 = " 1" Then
  36.             PictureBox2.BackgroundImage = My.Resources.icon2
  37.         ElseIf time Mod 6 = " 2" Then
  38.             PictureBox2.BackgroundImage = My.Resources.icon3
  39.         ElseIf time Mod 6 = " 3" Then
  40.             PictureBox2.BackgroundImage = My.Resources.icon4
  41.         ElseIf time Mod 6 = " 4" Then
  42.             PictureBox2.BackgroundImage = My.Resources.icon5
  43.         ElseIf time Mod 6 = " 5" Then
  44.             PictureBox2.BackgroundImage = My.Resources.icon6
  45.         End If
  46.  
  47.  
  48.         If time <= 0 Then
  49.             Timer1.Enabled = False
  50.             time = 25
  51.         End If
  52.  
  53.         'FIGURE OUT HOW TO RESIZE IMAGE IF YOU WNAT TO USE THIS CODE
  54.        Dim z As String = "C:\Users\chongg\Documents\Visual Studio 2015\"
  55.         ' substitute values stored in the variables into the string. That's why we needed to convert them from int -> string earlier
  56.        Dim g As String = "Projects\SlotMachine\SlotMachine\Resources\slotpics\icon" + (picnumber) + ".PNG"
  57.         g = g.Replace(" ", "")
  58.         ' PictureBox2.Image = Image.FromFile(z + g)
  59.        ' PictureBox2.BackgroundImageLayout = ImageLayout.Stretch
  60.  
  61.  
  62.         If Timer1.Enabled = False Then
  63.             If picnumber = " 1" Then
  64.                 PictureBox2.BackgroundImage = My.Resources.icon1
  65.             ElseIf picnumber = " 2" Then
  66.                 PictureBox2.BackgroundImage = My.Resources.icon2
  67.             ElseIf picnumber = " 3" Then
  68.                 PictureBox2.BackgroundImage = My.Resources.icon3
  69.             ElseIf picnumber = " 4" Then
  70.                 PictureBox2.BackgroundImage = My.Resources.icon4
  71.             ElseIf picnumber = " 5" Then
  72.                 PictureBox2.BackgroundImage = My.Resources.icon5
  73.             Else
  74.                 PictureBox2.BackgroundImage = My.Resources.icon6
  75.             End If
  76.         End If
  77.  
  78.  
  79.         'if you dont get three in a row, you lose the bet
  80.  
  81.     End Sub
  82.  
  83.  
  84.  
  85.  
  86.     Private Sub SpinButton_Click(sender As Object, e As EventArgs) Handles SpinButton.Click
  87.         Randomize()
  88.         Timer1.Enabled = True
  89.         Timer2.Enabled = True
  90.         Timer3.Enabled = True
  91.  
  92.  
  93.         totalamount_label.Text = totalcash
  94.  
  95.         'If totalcash >= 0 Then
  96.        '    notenoughmoney_label.Visible = True
  97.        '    Application.Exit() 'get rid of this and change to something else
  98.        'End If
  99.  
  100.  
  101.         picnumber = Str((Int(Rnd() * 6) + 1))
  102.         Label2.Text = picnumber
  103.         picnumber2 = Str((Int(Rnd() * 6) + 1))
  104.         Label4.Text = picnumber2
  105.         picnumber3 = Str((Int(Rnd() * 6) + 1))
  106.         Label6.Text = picnumber3
  107.  
  108.  
  109.  
  110.         'if PictureBox2 = PictureBox3 = PictureBox4 then
  111.        'totalcash = bet money + pay lines
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.     End Sub
  120.  
  121.     Private Sub PictureBox4_Click(sender As Object, e As EventArgs) Handles PictureBox4.Click
  122.  
  123.     End Sub
  124.  
  125.     Private Sub PictureBox2_Click(sender As Object, e As EventArgs) Handles PictureBox2.Click
  126.  
  127.     End Sub
  128.  
  129.     Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
  130.         Randomize()
  131.  
  132.  
  133.         time2 = time2 - 1
  134.         Label3.Text = time2
  135.         ' picnumber2 = Str((Int(Rnd() * 6) + 1))
  136.        'Label4.Text = picnumber2
  137.  
  138.  
  139.         If time2 Mod 6 = " 0" Then
  140.             PictureBox3.BackgroundImage = My.Resources.icon1
  141.         ElseIf time2 Mod 6 = " 1" Then
  142.             PictureBox3.BackgroundImage = My.Resources.icon2
  143.         ElseIf time2 Mod 6 = " 2" Then
  144.             PictureBox3.BackgroundImage = My.Resources.icon3
  145.         ElseIf time2 Mod 6 = " 3" Then
  146.             PictureBox3.BackgroundImage = My.Resources.icon4
  147.         ElseIf time2 Mod 6 = " 4" Then
  148.             PictureBox3.BackgroundImage = My.Resources.icon5
  149.         ElseIf time2 Mod 6 = " 5" Then
  150.             PictureBox3.BackgroundImage = My.Resources.icon6
  151.         End If
  152.  
  153.  
  154.         'when you submit this you need three files
  155.        ' .exe file
  156.        ' pdf of the design
  157.        ' link to ur pastebin where ur going to copy all your code
  158.  
  159.         If time2 <= 0 Then
  160.             Timer2.Enabled = False
  161.             time2 = 47
  162.         End If
  163.  
  164.         If Timer2.Enabled = False Then
  165.             If picnumber2 = " 1" Then
  166.                 PictureBox3.BackgroundImage = My.Resources.icon1
  167.             ElseIf picnumber2 = " 2" Then
  168.                 PictureBox3.BackgroundImage = My.Resources.icon2
  169.             ElseIf picnumber2 = " 3" Then
  170.                 PictureBox3.BackgroundImage = My.Resources.icon3
  171.             ElseIf picnumber2 = " 4" Then
  172.                 PictureBox3.BackgroundImage = My.Resources.icon4
  173.             ElseIf picnumber2 = " 5" Then
  174.                 PictureBox3.BackgroundImage = My.Resources.icon5
  175.             Else
  176.                 PictureBox3.BackgroundImage = My.Resources.icon6
  177.             End If
  178.         End If
  179.  
  180.  
  181.     End Sub
  182.  
  183.     Private Sub Timer3_Tick(sender As Object, e As EventArgs) Handles Timer3.Tick
  184.  
  185.  
  186.         Randomize()
  187.         time3 = time3 - 1
  188.         Label5.Text = time3
  189.         ' picnumber3 = Str((Int(Rnd() * 6) + 1))
  190.        'Label6.Text = picnumber3
  191.  
  192.  
  193.         If time3 Mod 6 = " 0" Then
  194.             PictureBox4.BackgroundImage = My.Resources.icon2
  195.         ElseIf time3 Mod 6 = " 1" Then
  196.             PictureBox4.BackgroundImage = My.Resources.icon6
  197.         ElseIf time3 Mod 6 = " 2" Then
  198.             PictureBox4.BackgroundImage = My.Resources.icon3
  199.         ElseIf time3 Mod 6 = " 3" Then
  200.             PictureBox4.BackgroundImage = My.Resources.icon4
  201.         ElseIf time3 Mod 6 = " 4" Then
  202.             PictureBox4.BackgroundImage = My.Resources.icon5
  203.         ElseIf time3 Mod 6 = " 5" Then
  204.             PictureBox4.BackgroundImage = My.Resources.icon1
  205.         End If
  206.  
  207.  
  208.         'when you submit this you need three files
  209.        ' .exe file
  210.        ' pdf of the design
  211.        ' link to ur pastebin where ur going to copy all your code
  212.  
  213.         If time3 <= 0 Then
  214.             Timer3.Enabled = False
  215.             time3 = 75
  216.         End If
  217.  
  218.         If Timer3.Enabled = False Then
  219.             If picnumber3 = " 1" Then
  220.                 PictureBox4.BackgroundImage = My.Resources.icon1
  221.             ElseIf picnumber3 = " 2" Then
  222.                 PictureBox4.BackgroundImage = My.Resources.icon2
  223.             ElseIf picnumber3 = " 3" Then
  224.                 PictureBox4.BackgroundImage = My.Resources.icon3
  225.             ElseIf picnumber3 = " 4" Then
  226.                 PictureBox4.BackgroundImage = My.Resources.icon4
  227.             ElseIf picnumber3 = " 5" Then
  228.                 PictureBox4.BackgroundImage = My.Resources.icon5
  229.             Else
  230.                 PictureBox4.BackgroundImage = My.Resources.icon6
  231.             End If
  232.         End If
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.     End Sub
  240.  
  241.     Private Sub bet_max_button_Click(sender As Object, e As EventArgs) Handles bet_max_button.Click
  242.  
  243.         If totalcash >= 0 Then
  244.             betmoneymax = totalcash
  245.             betmoney_label.Text = betmoneymax
  246.  
  247.         End If
  248.  
  249.     End Sub
  250.  
  251.     Private Sub bet_one_button_Click(sender As Object, e As EventArgs) Handles bet_one_button.Click
  252.  
  253.         If totalcash >= 0 Then
  254.             betmoney = betmoney + 10
  255.             betmoney_label.Text = betmoney
  256.  
  257.         End If
  258.  
  259.  
  260.     End Sub
  261. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement