Private Sub Command1_Click()Set Picture1.Picture = NothingFor i = 1 To 2AddPasNext'写入输出文件SavePicture Picture1.Image,"c:/1.bmp"MsgBox "验证码已经保存在:" & "c:/1.bmp",vbInformationEnd Sub'由于每个RBG分量值越大颜色越深,因此我们用下面两条语句就可以增强颜色的对比度:Private Sub Form_Load()Picture1.ForeColor = RGB(Rnd * 255,Rnd * 255,Rnd * 255)Picture1.BackColor = RGB(Rnd * 55,Rnd * 55,Rnd * 55)End SubSub AddPas()On Error GoTo Err1Picture1.Print Space(10 - Len(Result)); ResultDim x,y,x1,x2,i As Integer'为验证码添加随机直线For i = 1 To (Int(Rnd(1) * 100) + 1) x = Int(Rnd * Picture1.Width): y = Int(Rnd * Picture1.Height) x1 = Int(Rnd * Picture1.Width): Y1 = Int(Rnd * Picture1.Height) Picture1.Line (x,y)-(x1,Y1),RGB(Rnd * 255,Rnd * 255)Next i'为验证码随机添加圆点For i = 1 To (Int(Rnd(1) * 200) + 100) Picture1.PSet (Picture1.Width * Rnd,Picture1.Height * Rnd),_ RGB(Rnd * 255,Rnd * 255)Next i'随机决定输出字体样式Picture1.FontItalic = Int(Rnd * 2)Picture1.FontUnderline = Int(Rnd * 2)Picture1.ForeColor = RGB(Rnd * 155 + 100,Rnd * 155 + 100,Rnd * 155 + 100)Picture1.AutoRedraw = TruePicture1.FontName = "宋体"Picture1.FontSize = 20Picture1.CurrentX = 50Picture1.CurrentY = 50Picture1.Print Text1.textExit SubErr1:MsgBox "出现一个错误鸟"End Sub
原文链接:https://www.f2er.com/vb/263248.html