这是个vb6的BINGO小游戏的代码 如果要源程序 去我资料里找我网盘的地址 下载bingo.rar
Option Explicit
Private iSumA As IntegerPrivate iSumB As Integer
Private Sub Command1_Click()
Dim i As Integer
Dim j As Integer
Call S_Clear(1)
If F_CheckAll = False Then Exit Sub
For j = 0 To 3
For i = 0 To 3
If Val(Text(j).Text) = Val(Label(i).Caption) Then
If i = j Then
iSumA = iSumA + 1
Else
iSumB = iSumB + 1
End If
End If
Next
Next
Call S_Show
End Sub
Private Sub S_Clear(Optional iKB As Integer = 0)
Dim i As Integer
If iKB = 0 Then
For i = 0 To 3
Label(i).Caption = ""
Text(i).Text = ""
Next
End If
iSumA = 0
iSumB = 0
Label5.Caption = ""
End Sub
Private Sub S_Start()
Dim i As Integer
For i = 0 To 3
Label(i).Visible = False
Label(i).Caption = F_iGetRandomize(i)
Next
End Sub
Private Sub S_Show()
Dim stemp As String
Dim i As Integer
For i = 1 To iSumA
stemp = stemp & "A"
Next
For i = 1 To iSumB
stemp = stemp & "B"
Next
If iSumA + iSumB = 0 Then
Label5.Caption = "0000"
Else
Label5.Caption = stemp
End If
If iSumA = 4 Then
For i = 0 To 3
Label(i).Visible = False
Label(i).Caption = F_iGetRandomize(i)
Next
MsgBox "Bingo", vbOKOnly, "Flying Frog"
Command2.Value = True
DoEvents
Text(0).SetFocus
End If
End Sub
Private Sub Command2_Click()
Call S_Clear
Call S_Start
End Sub
Private Sub Form_Load()
Call S_Clear
Call S_Start
End Sub
Private Function F_iGetRandomize(ByVal iKB As Integer) As Integer
Dim num As Integer
Start:
Randomize
num = Rnd * (9 - 1) + 1
Select Case iKB
Case 0
F_iGetRandomize = num
Case 1
If num <> Val(Label(0).Caption) And _
num <> Val(Label(2).Caption) And _
num <> Val(Label(3).Caption) Then
F_iGetRandomize = num
Else
GoTo Start
End If
Case 2
If num <> Val(Label(0).Caption) And _
num <> Val(Label(2).Caption) And _
num <> Val(Label(3).Caption) Then
F_iGetRandomize = num
Else
GoTo Start
End If
Case 3
If num <> Val(Label(0).Caption) And _
num <> Val(Label(1).Caption) And _
num <> Val(Label(2).Caption) Then
F_iGetRandomize = num
Else
GoTo Start
End If
End Select
End Function
Private Function F_CheckText(ByVal iIndex As Integer) As Boolean
F_CheckText = False
If Val(Text(iIndex).Text) = 0 Then
Text(iIndex).SetFocus
MsgBox "Must Input", vbCritical, "Flying Frog"
Exit Function
End If
Select Case iIndex
Case 0
If Val(Text(iIndex).Text) = Val(Text(1).Text) Or _
Val(Text(iIndex).Text) = Val(Text(2).Text) Or _
Val(Text(iIndex).Text) = Val(Text(3).Text) Then
Text(iIndex).SetFocus
MsgBox "Same Number", vbCritical, "Flying Frog"
Exit Function
End If
Case 1
If Val(Text(iIndex).Text) = Val(Text(0).Text) Or _
Val(Text(iIndex).Text) = Val(Text(2).Text) Or _
Val(Text(iIndex).Text) = Val(Text(3).Text) Then
Text(iIndex).SetFocus
MsgBox "Same Number", vbCritical, "Flying Frog"
Exit Function
End If
Case 2
If Val(Text(iIndex).Text) = Val(Text(0).Text) Or _
Val(Text(iIndex).Text) = Val(Text(1).Text) Or _
Val(Text(iIndex).Text) = Val(Text(3).Text) Then
Text(iIndex).SetFocus
MsgBox "Same Number", vbCritical, "Flying Frog"
Exit Function
End If
Case 3
If Val(Text(iIndex).Text) = Val(Text(0).Text) Or _
Val(Text(iIndex).Text) = Val(Text(1).Text) Or _
Val(Text(iIndex).Text) = Val(Text(2).Text) Then
Text(iIndex).SetFocus
MsgBox "Same Number", vbCritical, "Flying Frog"
Exit Function
End If
End Select
F_CheckText = True
End Function
Private Function F_CheckAll() As Boolean
Dim i As Integer
F_CheckAll = False
For i = 0 To 3
If F_CheckText(i) = False Then Exit Function
Next
F_CheckAll = True
End Function
Private Sub Text_GotFocus(Index As Integer)
Text(Index).SelStart = 0
Text(Index).SelLength = Len(Text(Index).Text)
End Sub
Private Sub Text_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
If F_CheckText(Index) = False Then Exit Sub
End If
S_gKeySend (KeyCode)
End Sub
Private Sub Text_KeyPress(Index As Integer, KeyAscii As Integer)
KeyAscii = F_gKeypressNumber(Text(Index), KeyAscii, 1)
End Sub
多小的程序 多少行算小 多少行算大
我有个VB计算器,自己编的