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
Label2.Caption?=?"恭喜妳中得壹等獎"
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