Dim i, a(34), b(7)
Randomize: Cls
For i = 1 To 7
b(i) = Int(Rnd * 34 + 1)
If a(b(i)) Then i = i - 1 Else a(b(i)) = 1
Next
Print "34 选 7组 福利彩票系统,中奖号码:"
For i = 1 To 7
Print b(i)
Next
End Sub
请不要发违规广告,是违法行为
Private Sub Command1_Click()
If IsNumeric(Text1) And Len(Text1) = 7 Then '判断输入的是否为7位数字
Randomize
a = Format(Int(Rnd * 9999999 + 1), "0000000") '生成开奖号码
Label1.Caption = "本期开奖号码为:" & a
For i = 1 To 7 '逐位判断是否相同,b为相同个数
If Mid(Text1, i, 1) = Mid(a, i, 1) Then
b = b + 1
End If
Next
If b = 7 Then
ElseIf b = 6 Then
Label2.Caption = "恭喜你中得二等奖"
ElseIf b = 5 Then
Label2.Caption = "恭喜你中得三等奖"
'以此类推判断是否中奖
Else
Label2.Caption = "很遗憾,差一点就中奖了"
End If
Else
MsgBox "请输入一个七位数字"
Exit Sub
End If
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)