1、打开VB。
2、绘制控件:TextBox,PictureBox,Label,CommandButton。
3、添加代码:Dim vCode As StringPrivate Sub drawvc() '伍啪怪顼显示校验码Dim i, vc, px, py As LongDim r, g, b As ByteRandomize '初始化随机种子'生成随机校验码vc = CLng(8999 * Rnd + 1000)vCode = vc'显示校验码Picture1.ClsPicture1.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)NextEnd SubPrivate Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)drawvcEnd SubPrivate Sub Command2_Click()If Text1.Text = vCode Then MsgBox "验证码正确。", vbInformation + vbSystemModal, "正确" frmLand.MousePointer = 13 Timer1.Enabled = TrueElse MsgBox "验证码错误。", vbCritical + vbSystemModal, "错误" Text1.Text = "" drawvcEnd IfEnd SubPrivate Sub Form_Load()Picture1.FontSize = 12Picture1.FontBold = TruePicture1.AutoRedraw = TruedrawvcEnd Sub
4、完成。