这篇文章将为大家详细讲解有关VB.NET中怎么获取中文验证码,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。
专注于为中小企业提供成都网站建设、网站制作服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业代县免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了上千余家企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。
VB.net菜单:项目 --> XXX 属性... --> 配置 --> 优化 --> 选中“移除整数溢出检查”复选框
下面来仔细研究一下VB.NET中文验证码的相关代码编写:
Function RndStr()Function
RndStr() As String
Dim gb As SystemSystem.Text.
Encoding = System.Text.Encoding.
GetEncoding("gb2312")
Dim bytes As Object() =
CreateRegionCode(4)
Dim str1 As String = gb.GetString
(DirectCast(Convert.ChangeType
(bytes(0), GetType(Byte())), Byte()))
Dim str2 As String = gb.GetString
(DirectCast(Convert.ChangeType
(bytes(1), GetType(Byte())), Byte()))
Dim str3 As String = gb.GetString
(DirectCast(Convert.ChangeType
(bytes(2), GetType(Byte())), Byte()))
Dim str4 As String = gb.GetString
(DirectCast(Convert.ChangeType
(bytes(3), GetType(Byte())), Byte()))
Dim txt As String = (str1 &
str2 & str3 & str4)
End Function
Function CreateRegionCode()Function
CreateRegionCode(ByVal strlength
As Integer) As Object()
Dim rBase As String() = New String()
{"0", "1", "2", "3", "4", "5",
"6", "7", "8", "9", "a", "b",
"c", "d", "e", "f"}
Dim rnd As New Random
Dim bytes As Object() = New
Object(strlength - 1) {}
Dim i As Integer = 0
Do While (i < strlength)
Dim r2 As Integer
Dim r4 As Integer
Dim r1 As Integer = rnd.Next(11, 14)
Dim str_r1 As String = rBase(r1).Trim
rnd = New Random(r1 * DateTime.
Now.Ticks + i)
If (r1 = 13) Then
r2 = rnd.Next(0, 7)
Else
r2 = rnd.Next(0, &H10)
End If
Dim str_r2 As String = rBase(r2).Trim
Dim r3 As Integer = New Random(
(r2 * DateTime.Now.Ticks) + i).
Next(10, &H10)
Dim str_r3 As String = rBase(r3).Trim
rnd = New Random((r3 * DateTime.
Now.Ticks) + i)
Select Case r3
Case 10
r4 = rnd.Next(1, &H10)
Exit Select
Case 15
r4 = rnd.Next(0, 15)
Exit Select
Case Else
r4 = rnd.Next(0, &H10)
Exit Select
End Select
Dim str_r4 As String = rBase(r4).Trim
Dim byte1 As Byte = Convert.
ToByte((str_r1 & str_r2), &H10)
Dim byte2 As Byte = Convert.
ToByte((str_r3 & str_r4), &H10)
Dim str_r As Byte() = New Byte()
{byte1, byte2}
bytes.SetValue(str_r, i)
i += 1
Loop
Return bytes
End Function
关于VB.NET中怎么获取中文验证码就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。
当前名称:VB.NET中怎么获取中文验证码
本文网址:https://www.cdcxhl.com/article2/gdhhic.html
成都网站建设公司_创新互联,为您提供企业网站制作、App设计、服务器托管、、移动网站建设、标签优化
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联