编写VB程序,功能为:单击“发牌”按钮“Command1”后,从一副扑克牌(不包括大王、小王、J、Q、K、A)中随机抽取5张牌,牌的花色(♠♥♣♦)忽略,显示在列表框“List1”中。如果这5张牌由一个对子和一个顺子(3张牌连续)组成,则在标签“Label1”中显示“运气不错:)”,否则显示“运气一般:|”。程序运行界面如图所示。
实现上述功能的VB程序如下:
Private Sub Command1_Click()
List1.Clear
Dim five(1 To 5) As Integer
Dim i As Integer, j As Integer, k As Integer
Dim p As Integer, find_pair As Boolean
'随机抽取5张牌,将牌的点数存储在数组five中,并在List1中显示。代码略
i = 5: p = 1: find_pair = False
Do While i>= 2
j=p
Do While j <= i - 1
If five(j) > five(j + 1) Then
t = five(j): five(j) = five(j + 1): five(j + 1) = t
ElseIf five(j) = five(j + 1) And Not find_pair Then
t = five(1): five(1) = five(j): five(j) = t
t = five(2): five(2) = five(j + 1): five(j + 1) = t
find_pair = True
i = i + 1
p = _____________
Exit Do
End If
j = j + 1
Loop
i = i - 1
Loop
k = 0
For i = 3 To 4
If Then k = k + 1
Next i
If five(1) = five(2) And k = 2 Then
Label1.Caption = "运气不错:)"
Else
Label1.Caption = "运气一般:|"
End If
End Sub
请回答下列问题: