Я бегу кругами, пытаясь получить этот бит кода, который я написал, чтобы просто добавить сумму ставки, запустить цикл и добавить сумму ставки и т. Д. Если вы проиграете, добавьте ее в потеря метки, цикл и, наконец, отслеживать количество раз, когда вы делаете ставку.Vb program loop с вложенными операциями if
Можете ли вы помочь мне выправить это?
Option Strict Off
Public Class RaceSeries
' declare variables
Const intMAX_INDEX As Integer = 0
Dim intBetValue As String
Dim intBetValue2 As String
Dim intRacerNum As String
Dim Count As Integer
Dim intNum As Integer
Dim rand As New Random
Dim decGuess As Decimal
Dim intBet As Integer
Dim blnFlag1 As Boolean
Dim blnFlag2 As Boolean
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btnBack.Click
Me.Close()
End Sub
Private Sub btnBetOnRace_Click(sender As Object, e As EventArgs) Handles btnBetOnRace.Click
'activate sound clip
My.Computer.Audio.Play(My.Resources.FlyBy,
AudioPlayMode.Background)
'verify Input() Is numeric and get bet amount
intBetValue = InputBox("How much would you like to bet?")
If IsNumeric(intBetValue) Then
MsgBox("You are betting " & CInt(intBetValue).ToString("C"))
blnFlag1 = True
Else
MsgBox("You provided an invalid value")
blnFlag1 = False
End If
End Sub
Private Sub btnPick_Click(sender As Object, e As EventArgs) Handles btnPick.Click
' verify input and get racer number
intRacerNum = InputBox("Choose the racer you would like to bet on")
If IsNumeric(intRacerNum) And intRacerNum < 7 And intRacerNum >= 1 Then
MsgBox("You have picked racer # " & CInt(intRacerNum).ToString)
blnFlag2 = True
Else
MsgBox("Choose a racer # 1-6")
blnFlag2 = False
End If
End Sub
Private Sub btnStart_Click(sender As Object, e As EventArgs) Handles btnStart.Click
If blnFlag1 And blnFlag2 = True Then
Do While Count <= intMAX_INDEX
Count += 1
'get a random integer and assign it to intnum
intNum = rand.Next(6)
If intNum <> intRacerNum Then
intBetValue = intBetValue * Count
lblLost.Text = intBetValue
MsgBox("Your Rider Lost The Race")
lblDailyBets.Text = Count
Exit Do
ElseIf intNum = intRacerNum Then
intBetValue = intBetValue * Count
lblLost.Text = intBetValue
lblWinnings.Text = intBetValue
MsgBox("Congratulations, Your Rider Won The Race")
End If
lblDailyBets.Text = Count
Loop
Else
MsgBox("You must enter a bet and pick a racer")
End If
End Sub
End Class
Только этот вариант «Strict Off» заставляет меня уйти от этого quesiton. – Eminem
Предполагается, что IntMAX_INDEX установлен на что-то отличное от нуля? – ChicagoMike
У меня было установлено 3 одновременно, а msgbox, который сказал «это гонка 3 серии» – corvette1