野猫III 发表于 2006-8-1 09:17:42

请问这个VB KeyGen的用户名如何随机产生?

软件实例引用于:
https://www.chinapyg.com/viewthread.php?tid=6580&extra=page%3D1

看咱当苦力做的取用户名不成功随机的KeyGen.

Private Sub Command1_Click()
Dim a, b, c, d, e, f, g, h, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z As String
Dim a1, a2, a3, a4, a5, a6, a7, a8, a9 As String
Dim b1, b2, b3, b4, b5, b6, b7, b8, b9 As String
Dim c1, c2, c3, c4, c5, c6, c7, c8, c9 As String

a = "JAGD38-jowBN3K"
b = "KOB82j-ncVBN8k"
c = "VXV96J-WU76yw"
d = "BNCE8H-Pmx87by"
f = "CXZ93z-nbBP93Y"
g = "BOXLR6-8hvg8C"

Text1.Text = a
Text1.Text = b
Text1.Text = c
Text1.Text = d
Text1.Text = f
Text1.Text = g

For i = 1 To Len(Text1.Text)
CodeA = CodeA + Asc(Mid(Text1.Text, i, 1))
Next i

CodeB = CodeA * &HBE755 + &HC0F97
CodeC = CodeB \ 2 + &H4A2FFE3

Text2.Text = CodeC

End Sub

[ 本帖最后由 野猫III 于 2006-8-1 20:34 编辑 ]

hrbx 发表于 2006-8-1 12:42:59

将用户名定义成字符串数组,每次点击”注册“按钮时,先Rnd()生成随机数,随机数的范围为字符串数组的
上下界,用产生的随机数作为字符串数组的下标取字符串数组,将取得的字符串作为用户名即可。
例:设Rnd()产生一个随机数7,则取st(7)作为用户名。
PS:按你的代码写的话,用户名似乎只能取最后一个吧?

[ 本帖最后由 hrbx 于 2006-8-1 13:08 编辑 ]

野猫III 发表于 2006-8-1 13:53:22

原帖由 hrbx 于 2006-8-1 12:42 发表
将用户名定义成字符串数组,每次点击”注册“按钮时,先Rnd()生成随机数,随机数的范围为字符串数组的
上下界,用产生的随机数作为字符串数组的下标取字符串数组,将取得的字符串作为用户名即可。
例:设Rnd()产 ...

是的,兄弟说的这种方法咱事先也考虑过,现在就实践一下。。。

hbqjxhw 发表于 2006-8-1 14:11:02

原帖由 hrbx 于 2006-8-1 12:42 发表
将用户名定义成字符串数组,每次点击”注册“按钮时,先Rnd()生成随机数,随机数的范围为字符串数组的
上下界,用产生的随机数作为字符串数组的下标取字符串数组,将取得的字符串作为用户名即可。
例:设Rnd()产 ...
的确是这样的,我也学习一下。

野猫III 发表于 2006-8-1 14:44:30

原帖由 hbqjxhw 于 2006-8-1 14:11 发表

的确是这样的,我也学习一下。

刚才搞了许久,搞不来~ Text1.text显示的内容还是随机数。。。

hrbx 发表于 2006-8-1 19:29:36

试试以下的方法,应该就没问题了。:)



Private Sub Command1_Click()
Dim Tmp As Integer
Dim Str(20) As String'定义字符串数组

Randomize
Tmp = Int(Rnd() * 9) '产生0-9的随机数,以用户名个数为10个为例

Str(0) = "JAGD38-jowBN3K"
Str(1) = "KOB82j-ncVBN8k"
Str(2) = "VXV96J-WU76yw"
Str(3) = "BNCE8H-Pmx87by"
Str(4) = "CXZ93z-nbBP93Y"
Str(5) = "BOXLR6-8hvg8C"
Str(6) = "IOAP69-hob38YX"
Str(7) = "HGSOhox-bnr29h"
Str(8) = "YWT6682-hoa46I"
Str(9) = "PEUBN-GHWPhfo8"


Text1.Text = Str(Tmp)

End Sub

野猫III 发表于 2006-8-1 20:33:46

3Q!

Private Sub Command1_Click()
Dim Tmp As Integer
Dim Str(49) As String'定义字符串数组 byhrbx

Randomize
Tmp = Int(Rnd() * 9) + Int(Rnd() * 9) + Int(Rnd() * 9) + Int(Rnd() * 9) + Int(Rnd() * 9) + Int(Rnd() * 5)
'产生0-9的随机数,以用户名个数为10个为例

Str(1) = "JAGD38-jowBN3K"
Str(2) = "KOB82j-ncVBN8k"
Str(3) = "VXV96J-WU76yw"
Str(4) = "BNCE8H-Pmx87by"
Str(5) = "CXZ93z-nbBP93Y"
Str(6) = "BOXLR6-8hvg8C"
Str(7) = "IOAP69-hob38YX"
Str(8) = "HGSOhox-bnr29h"
Str(9) = "YWT6682-hoa46I"

Str(10) = "PEUBN-GHWPhfo8"
Str(11) = "OWJZ-689hneGHO"
Str(12) = "GHOS-69GJjogHI"
Str(13) = "WOR-86otuw25jkU"
Str(14) = "VBNJWOW-698jaow"
Str(15) = "EIR-03hiwTRIT"
Str(16) = "BVXN6-JS67juYO"
Str(17) = "XNOC-6jgd86sfT"
Str(18) = "QOWF5-8hwoXNV"
Str(19) = "NBUW6-29yi6WT"

Str(20) = "So4p6-5ywOWNB"
Str(21) = "KNsjM6-XNyxVUS"
Str(22) = "VN6jxiS-PwIOyrX"
Str(23) = "PKLa6fB-Nl5KaY"
Str(24) = "OwdQI7bW-R1OhMX"
Str(25) = "KOtI32Q-TnkUQW"
Str(26) = "HouYJj-J5KhySD"
Str(27) = "ASiJriO-IwdWiUR"
Str(28) = "ON9L3A-JKyROI"
Str(29) = "IrOHepBjK-J8S"
Str(30) = "Is3Q-UTjNe6DK"
Str(31) = "M7BdN-L9Js2UT"
Str(32) = "Ui4gY-OyIA3bfJ"
Str(33) = "GjUm3-hTPicESV"
Str(34) = "TdEhsN5-O7utB"
Str(35) = "TOqD9SK-PyOjW"
Str(36) = "EPhA3WkU-RdY"
Str(37) = "OaoPiU-zTwHOW"
Str(38) = "OxhWET-UuDlwH"
Str(39) = "HxsF6e-gyMFdSB"

Str(40) = "UjOTfoY-FDq3iHF"
Str(41) = "UnVzN6E-QsiHngS"
Str(42) = "YgjM-0oiPyeS"
Str(43) = "Nt3bB-dTRt9yOR"
Str(44) = "EOuiM-BDTq3kLB"
Str(45) = "XKnFU-SIfsIU"
Str(46) = "KFiY-O1AlV0zGE"
Str(47) = "PQaZ0O-UwtGlXZ"
Str(48) = "Fq0cL-sO0YFpyX"
Str(49) = "Dek-iW1ylR0veK"
Str(0) = "vrlL7KbO-0xaQ"

Text1.Text = Str(Tmp)

For i = 1 To Len(Text1.Text)
CodeA = CodeA + Asc(Mid(Text1.Text, i, 1))
Next i

CodeB = CodeA * &HBE755 + &HC0F97
CodeC = CodeB \ 2 + &H4A2FFE3

Text2.Text = CodeC

End Sub

hbqjxhw 发表于 2006-8-2 09:29:23

原帖由 野猫III 于 2006-8-1 20:33 发表
3Q!

Private Sub Command1_Click()
Dim Tmp As Integer
Dim Str(49) As String'定义字符串数组 byhrbx

Randomize
Tmp = Int(Rnd() * 9) + Int(Rnd() * 9) + Int(Rnd() * 9) + Int(Rnd() * 9) + Int( ...
/:D
页: [1]
查看完整版本: 请问这个VB KeyGen的用户名如何随机产生?