Vb6 Visual Basic 6游戏“;21“;必要时不显示MsgBox

Vb6 Visual Basic 6游戏“;21“;必要时不显示MsgBox,vb6,Vb6,尝试在VisualBasic6中制作游戏“21”,我已经完成了所有操作,但是MsgBox在半身像或21点时没有显示。有什么想法吗 Private Sub cmdCheckScore_Click() lblPC1.Visible = True lblPC2.Visible = True lblPC3.Visible = True End Sub Private Sub cmdDrawCard_Click() If lblDraw1.Caption = "" Then 'Draws 3

尝试在VisualBasic6中制作游戏“21”,我已经完成了所有操作,但是MsgBox在半身像或21点时没有显示。有什么想法吗

Private Sub cmdCheckScore_Click()
lblPC1.Visible = True
lblPC2.Visible = True
lblPC3.Visible = True



End Sub

Private Sub cmdDrawCard_Click()



If lblDraw1.Caption = "" Then 'Draws 3 random numbers with 3 button clicks
intDraw1 = Int(Rnd * 10 + 1)
lblDraw1.Caption = intDraw1
ElseIf lblDraw2.Caption = "" Then
intDraw2 = Int(Rnd * 10 + 1)
lblDraw2.Caption = intDraw2
ElseIf lblDraw3.Caption = "" Then
intDraw3 = Int(Rnd * 10 + 1)
lblDraw3.Caption = intDraw3

End If

intPlayerScore = intPlayer1 + intPlayer2 + intDraw1 + intDraw2 + intDraw3
intComputerScore = intPC1 + intPC2 + intPC3


If intPlayerScore > 21 Then
MsgBox "Bust!"
ElseIf intPlayerScore = 21 Then
MsgBox "Blackjack!"
End If



End Sub
Private Sub Form_Load()
Randomize
Dim intPlayer1 As Integer
Dim intPlayer2 As Integer
Dim intPlayer3 As Integer
Dim intPC1 As Integer
Dim intPC2 As Integer
Dim intPC3 As Integer
Dim intDraw1 As Integer
Dim intDraw2 As Integer
Dim intDraw3 As Integer
Dim PlayerScore As Integer
Dim ComputerScore As Integer

intDraw1 = 0
intDraw2 = 0
intDraw3 = 0

intPlayer1 = Int(Rnd * 10 + 1)
intPlayer2 = Int(Rnd * 10 + 1)
lblPlayer1.Caption = intPlayer1
lblPlayer2.Caption = intPlayer2

intPC1 = Int(Rnd * 10 + 1)
intPC2 = Int(Rnd * 10 + 1)
intPC3 = Int(Rnd * 10 + 1)

lblPC1.Caption = intPC1
lblPC2.Caption = intPC2
lblPC3.Caption = intPC3
End Sub 

我已经花了两个小时试图解决这个问题,但仍然没有解决方案。

我相信您的变量是在范围之外创建的,因此当单击代码运行时,它们都是变体

将您的声明移出表单加载到以上cmdCheckScore

Dim intPlayer1作为整数显示在窗体顶部
Dim intPlayer2为整数
Dim intPlayer3为整数
整数形式的Dim intPC1
作为整数的Dim intPC2
整数形式的Dim intPC3
Dim intDraw1作为整数
Dim intDraw2作为整数
Dim intDraw3作为整数
Dim PlayerScore作为整数
将表格顶部的计算机分数设置为整数
私有子CMDCCheckScore\u Click()

接下来,单击左侧的“关闭”,并在此行上设置断点,以验证值是否已到达!
intPlayerScore=intPlayer1+intPlayer2+intDraw1+intDraw2+intDraw3

不是C#。也不是vba。为了获得更好的帮助,请确保尽可能详细地说明问题。另一件事是缩小它的范围,在本例中,问题在于值为0,而您预期的值为0。