- UID
- 418
- 精华
- 积分
- 3994
- 威望
- 点
- 宅币
- 个
- 贡献
- 次
- 宅之契约
- 份
- 最后登录
- 1970-1-1
- 在线时间
- 小时
|
应同学装逼需求,特写简单装逼向验证码生成算法,高手喷口留情,有兴趣的朋友看过来:
进来身体有恙,夜不能寐(非想妹子也),无暇打理生存。不少未完成之贴,望站长海涵。
开门见码:
- VERSION 5.00
- Begin VB.Form Form1
- Caption = "Form1"
- ClientHeight = 2940
- ClientLeft = 60
- ClientTop = 600
- ClientWidth = 4680
- LinkTopic = "Form1"
- ScaleHeight = 2940
- ScaleWidth = 4680
- StartUpPosition = 3 'Windows Default
- Begin VB.CommandButton Command2
- Caption = "OK"
- Enabled = 0 'False
- Height = 855
- Left = 2640
- TabIndex = 3
- Top = 840
- Width = 975
- End
- Begin VB.TextBox Text1
- Height = 285
- Left = 120
- TabIndex = 2
- Top = 1200
- Width = 2415
- End
- Begin VB.CommandButton Command1
- Caption = "Change"
- Height = 855
- Left = 2640
- TabIndex = 1
- Top = 0
- Width = 975
- End
- Begin VB.PictureBox P
- BackColor = &H00FFFFFF&
- ForeColor = &H00000000&
- Height = 855
- Left = 0
- ScaleHeight = 795
- ScaleWidth = 2595
- TabIndex = 0
- Top = 0
- Width = 2655
- End
- End
- Attribute VB_Name = "Form1"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Option Explicit '从这里算真正开始
- Dim ans As Single
- Private Sub Command1_Click()
- Randomize '初始化随机数生成器
- Command2.Enabled = True '免得不输就pass
- Dim a As Integer, b As Integer, c(3) As String, d As String
- 'a放第一个数,b放第二个数,c放操作符,d保存操作符
- Dim i As Integer '计数器变量留着待用
-
- c(1) = "+"
- c(2) = "-"
- c(3) = "*"
-
- a = Int(Rnd * 10 + 1) '第一个随机数
- b = Int(Rnd * 10 + 1) '第二个随机数
-
-
- P.Cls '清屏
- '第一个数
- P.FontName = Screen.Fonts(Int(Rnd * 15) + 1) '字体名
- P.FontSize = Int(Rnd * 16) + 8 '字号
- P.FontBold = CBool(Int(Rnd + 1)) '是否粗体
- P.FontItalic = CBool(Int(Rnd + 1)) '是否斜体
- P.ForeColor = RGB(Int(Rnd * 254 + 1), Int(Rnd * 254 + 1), Int(Rnd * 254 + 1)) '随机颜色
- '定位
- P.CurrentX = Int(Rnd() * 10) + 10
- P.CurrentY = Int(Rnd() * 50) + 1
- P.Print CStr(a) '打印
-
- 操作符
- P.FontName = Screen.Fonts(Int(Rnd * 15) + 1)
- P.FontSize = Int(Rnd * 16) + 8
- P.FontBold = CBool(Int(Rnd + 1))
- P.FontItalic = CBool(Int(Rnd + 1))
- P.ForeColor = RGB(Int(Rnd * 254 + 1), Int(Rnd * 254 + 1), Int(Rnd * 254 + 1))
- P.CurrentX = Int(Rnd() * 500) + 500
- P.CurrentY = Int(Rnd() * 50) + 1
- d = c(Int(Rnd * 3) + 1) '随机操作符
- P.Print d
-
- '第二个数字,原理同上,解释略
- P.FontName = Screen.Fonts(Int(Rnd * 15) + 1)
- P.FontSize = Int(Rnd * 16) + 8
- P.FontBold = CBool(Int(Rnd + 1))
- P.FontItalic = CBool(Int(Rnd + 1))
- P.ForeColor = RGB(Int(Rnd * 254 + 1), Int(Rnd * 254 + 1), Int(Rnd * 254 + 1))
- P.CurrentX = Int(Rnd() * 1000) + 1000
- P.CurrentY = Int(Rnd() * 50) + 1
- P.Print CStr(b)
-
- '瞎画一些线条
- For i = 1 To 7
- P.ForeColor = RGB(Int(Rnd * 254 + 1), Int(Rnd * 254 + 1), Int(Rnd * 254 + 1))
- P.Line (Rnd * P.ScaleWidth, Rnd * P.ScaleWidth)-(Rnd * P.ScaleWidth, Rnd * P.ScaleWidth)
- Next
- '瞎画一些点
- For i = 1 To 100
- P.ForeColor = RGB(Int(Rnd * 254 + 1), Int(Rnd * 254 + 1), Int(Rnd * 254 + 1))
- P.PSet (Rnd * P.ScaleWidth, Rnd * P.ScaleWidth)
- Next
-
- '判定运算,计算结果
- Select Case d
- Case "+"
- ans = a + b
- Case "-"
- ans = a - b
- Case "*"
- ans = a * b
- End Select
- End Sub
- Private Sub Command2_Click()
- If Val(Text1) = ans And Text1 <> "" Then
- MsgBox "Pass!", 48
- Else
- Call Command1_Click
- Text1 = ""
- End If
- End Sub
复制代码
|
|