Dim vCode As String
Private Sub Command1_Click()
drawvc
End Sub
Private Sub drawvc() '顯示校驗碼
Dim i, vc, px, py As Long
Dim r, g, b As Byte
Randomize '初始化隨機種子
'生成隨機校驗碼
vc = CLng(8999 * Rnd + 1000)
vCode = vc
'顯示校驗碼
Picture1.Cls
Picture1.Print vc
'添加噪點(防止自動圖像識別)
For i = 0 To 2000 '畫2000個噪點
'畫點隨機位置
px = CLng(Picture1.Width * Rnd)
py = CLng(Picture1.Height * Rnd)
'畫點隨機顏色
r = CByte(255 * Rnd)
g = CByte(255 * Rnd)
b = CByte(255 * Rnd)
Picture1.Line (px, py)-(px + 1, py + 1), RGB(r, g, b)
Next
End Sub
Private Sub Command2_Click()
If Text1.Text = vCode Then
MsgBox ("正確")
Else
MsgBox ("錯誤")
drawvc
End If
End Sub
Private Sub Form_Load()
Picture1.FontSize = 12
Picture1.FontBold = True
Picture1.AutoRedraw = True
drawvc
End Sub
妳也可以自己畫點其他的東西,增加識別難度