vb6 如何寫出序號製造機(並無非法用途)?

2015-11-20 4:30 am
例如: xxxx-xxxx-xxxx-xxxx-xxxx
xxxx<-隨機產生 (大寫英文/數字)

回答 (1)

2015-11-20 6:55 am
✔ 最佳答案
Sub Main()
Dim Serial As String = ""
Dim Num As Integer
Dim RndChr As Char
Randomize() '先亂數化
For i = 1 To 20 '序號共20個字
Do
Num = Rnd() * 90
RndChr = Chr(Num)
Loop While Not ((Num >= 48 And Num <= 57) Or (Num >= 65 And Num <= 90)) '大寫字母或數字
'Serial = Serial + RndChr
If i Mod 4 = 0 Then

Serial = Serial + RndChr
If i < 20 Then
Serial = Serial + "-"
End If
Else
Serial = Serial + RndChr
End If
Next
Console.WriteLine(Serial)
Console.ReadLine()

End Sub


收錄日期: 2021-04-21 17:16:55
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20151119203030AAUlhi7

檢視 Wayback Machine 備份