vb.net数字验证码 visual studio验证码( 四 )


'输出不同字体和颜色vb.net数字验证码的验证码字符
For i As Integer = 0 To checkCode.Length - 1
Dim cindex As Integer = rand.Next(7)
Dim findex As Integer = rand.Next(5)
Dim f As Font = New System.Drawing.Font("宋体", 12, System.Drawing.FontStyle.Regular)
Dim b As Brush = New System.Drawing.SolidBrush(c(cindex))
Dim ii As Integer = 4
If (i + 1) Mod 2 = 0 Then
ii = 2
End If
g.DrawString(checkCode.Substring(i, 1), f, b, 3 + (i * 12), ii)
Next i
'画一个边框
g.DrawRectangle(New Pen(Color.Black, 0), 0, 0, image.Width - 1, image.Height - 1)
'输出到浏览器
Dim ms As New System.IO.MemoryStream()
image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg)
Response.ClearContent()
Response.ContentType = "image/Jpeg"
Response.BinaryWrite(ms.ToArray())
g.Dispose()
image.Dispose()
End Sub
Private Function MakeValidateCode() As String
'0 i o
Dim s() As Char = { "0"c, "1"c, "2"c, "3"c, "4"c, "5"c, "6"c, "7"c, "8"c, "9"c, "A"c, "B"c, "C"c, "D"c, "E"c, "F"c, "G"c, "J"c, "K"c, "L"c, "M"c, "N"c, "P"c, "Q"c, "R"c, "S"c, "T"c, "U"c, "V"c, "W"c, "X"c, "Y"c, "Z"c }
Dim num As String = ""
Dim r As New Random()
For i As Integer = 0 To 3
num = s(r.Next(0, s.Length - 1)).ToString()
Next i
Return num
End Function
End Class
关于vb.net数字验证码和visual studio验证码的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。

推荐阅读