使用VB做验证码登陆

 时间:2026-04-26 16:16:56

1、打开VB。

使用VB做验证码登陆

2、绘制控件:TextBox,PictureBox,Label,CommandButton。

使用VB做验证码登陆

3、添加代码:

Dim vCode As String

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 Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

drawvc

End Sub

Private Sub Command2_Click()

If Text1.Text = vCode Then

    MsgBox "验证码正确。", vbInformation + vbSystemModal, "正确"

    frmLand.MousePointer = 13

    Timer1.Enabled = True

Else

    MsgBox "验证码错误。", vbCritical + vbSystemModal, "错误"

    Text1.Text = ""

    drawvc

End If

End Sub

Private Sub Form_Load()

Picture1.FontSize = 12

Picture1.FontBold = True

Picture1.AutoRedraw = True

drawvc

End Sub

4、完成。

  • VB动态创建组合框
  • VB实现在PC上通过手机发短消息
  • 用VB6.0快速实现图象加柔效果
  • 如何创建SQLSERVER数据库备份维护计划
  • 易语言——制作自己的小时钟 怎样写一个时钟
  • 热门搜索
    怎么做糖醋排骨 病假怎么扣工资 护发素怎么用 道奇酷威怎么样 化妆刷怎么清洗 公积金贷款额度怎么算 我的世界信标怎么用 我要怎么说我不爱你 苹果笔记本怎么用 百分之几怎么算