Advertisement
ssoni

craps.vb

Mar 10th, 2022
1,283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.40 KB | None | 0 0
  1. Public Class Form1
  2.  
  3.     Public funds As Integer
  4.     Public generator As New Random
  5.  
  6.  
  7.     Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  8.         lblDi1.Text = ""
  9.         lblDi2.Text = ""
  10.         lblMsg.Text = ""
  11.         funds = 100
  12.  
  13.  
  14.  
  15.     End Sub
  16.  
  17.     Private Sub btnRoll_Click(sender As Object, e As EventArgs) Handles btnRoll.Click
  18.         Dim roll1 As Integer
  19.         Dim roll2 As Integer
  20.         Dim total As Integer
  21.         Dim bet As Integer
  22.  
  23.         'get bet amount from textbox
  24.         bet = txtBet.Text
  25.  
  26.         'roll the die!!
  27.         roll1 = generator.Next(1, 7)
  28.         roll2 = generator.Next(1, 7)
  29.  
  30.         'display the rolls
  31.         lblDi1.Text = roll1
  32.         lblDi2.Text = roll2
  33.  
  34.         'update funds
  35.         total = roll1 + roll2
  36.         If total = 7 Or total = 11 Then
  37.             funds = funds + bet
  38.             lblMsg.Text = "You have $" & funds
  39.         ElseIf total = 2 Or total = 3 Or total = 6 Then
  40.             funds = funds - bet
  41.             lblMsg.Text = "You have $" & funds
  42.         End If
  43.  
  44.         'check if broke
  45.         If funds <= 0 Then
  46.             lblMsg.Text = "Go home, literal loser!"
  47.             btnRoll.Enabled = False
  48.         End If
  49.  
  50.     End Sub
  51.  
  52.     Private Sub btnAll_Click(sender As Object, e As EventArgs) Handles btnAll.Click
  53.         txtBet.Text = funds
  54.     End Sub
  55. End Class
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement