用VB做出 可以產生20個包含(英文單子和數字),一次產生100個
例如: 產生 dide5kf9dkvje5e236d qkeogojpb5fke8dh654r
VB介面包涵一個按鈕,一個text1
執行後結果產生在text1上
2006-02-26 08:18:12 · 3 個解答 · 發問者 ? 2 in 電腦與網際網路 ➔ 程式設計
先將Text1的 MultiLine屬性設定成 True以及 ScrollBars屬性設定成 2 - 垂直捲軸Private Sub Command1_Click() Dim Temp As String, i As Integer, j As Integer, R As Byte Text1 = "": Temp = "" For i = 1 To 100 '產生100組 For j = 1 To 20 '20個亂數英數字元 Randomize R = Int(Rnd * 2) If R = 0 Then Temp = Temp & Chr(Int(Rnd * (57 - 48 + 1)) + 48) Else Temp = Temp & Chr(Int(Rnd * (122 - 97 + 1)) + 97) End If Next Temp = Temp & vbCrLf Next Text1 = TempEnd Sub
2006-02-25 17:28:45 · answer #1 · answered by ? 6 · 0⤊ 0⤋
這個我也有做過,既然已經有人貼上程式碼了,那我就不貼囉!
2006-02-26 15:26:44 · answer #2 · answered by 世賢 7 · 0⤊ 0⤋
'表單置一個CommandButton及一個TextBox,TextBox的MultiLine設為True,ScrollBars設為2
Private Sub Command1_Click()
Dim I As Integer, J As Integer, N As Integer, S As String, Str As String
For I = 1 To 100 '產生100個
Randomize: S = "" '初始亂數及S
For J = 1 To 20 '產生20個字
Do
N = Int(Rnd * 75 + 48) '亂數產生48~122間之值
Loop Until N < 58 Or (N > 64 And N < 91) Or N > 96 '若Chr(N)為數字或英文字離開迴圈
S = S & Chr(N) '記錄到S變數
Next
Str = Str & S & vbCrLf '記錄到Str變數+換行
Next
Text1 = Left(Str, Len(Str) - 1) '將結果計顯示在Text1
End Sub
2006-02-25 17:38:30 · answer #3 · answered by W.J.S. 7 · 0⤊ 0⤋