小弟没学过VB。最近要一个小程序急用。感谢各位大哥帮个忙
该程序面板上有2个文本框,一个按钮。
点击按钮后,自动根据前缀文本框里的前缀,以及另一个文本框里的数量。
自动生成帐号,外加随机的密码。写入一个文本文件。Private Sub Command1_Click()
prefix = Text1.Text
Number = Text2.Text
我写到这里就不知道怎么写了
End Sub急急急~~~~~ 请大家帮忙。
该程序面板上有2个文本框,一个按钮。
点击按钮后,自动根据前缀文本框里的前缀,以及另一个文本框里的数量。
自动生成帐号,外加随机的密码。写入一个文本文件。Private Sub Command1_Click()
prefix = Text1.Text
Number = Text2.Text
我写到这里就不知道怎么写了
End Sub急急急~~~~~ 请大家帮忙。
Dim fso As New FileSystemObject
Dim fil As File
Dim ts As TextStream
Dim filename As String
Dialog1.CancelError = True
On Error GoTo Err
Dialog1.Filter = "所有文件(*.*)|*.*|文本文件(*.txt))|*.txt"
Dialog1.FilterIndex = 2
Dialog1.Flags = cdlOFNOverwritePrompt '使“另存为”对话框当选择的文件已经存在时应产生一个信息框,用户必须确认是否覆盖该文件。
Dialog1.ShowSave
filename = Dialog1.filename
Set fso = CreateObject("Scripting.FileSystemObject")
fso.CreateTextFile (filename)
Set fil = fso.GetFile(filename)
Set ts = fil.OpenAsTextStream(ForWriting)
ts.Write (Text1.Text)
ts.Close
Err:
Exit Sub
End Sub
Dim TextLine
Open "TESTFILE" For Input As #1 ' Open file.
Do While Not EOF(1) ' Loop until end of file.
Line Input #1, TextLine ' Read line into variable.
Debug.Print TextLine ' Print to the Immediate window.
Loop
Close #1 ' Close file.
比如说我前缀输入了 ccc .数量要100个。
那么 生成一个叫 account.txt的文件里就是这个样子
ccc1 ****
ccc2 ****
ccc3 ****
ccc4 ****(****为为每个生成的随机数) 能帮我改得好点吗? 谢谢。因为VB我一点都不懂
On Error Resume Next
Dim i As Long, s As String, j As Long
Dim temps As String
If num <= 0 Then
MsgBox "error"
Exit Sub
End If
'生成数据
If num = 1 Then
Randomize Time
j = CLng(Rnd(i) * maxnum) + 1
s = str + " " + CStr(j)
Else
For i = 1 To num - 1
Randomize Time
j = CLng(Rnd(i) * maxnum) + 1
temps = str + " " + CStr(j)
s = s + temps + vbCrLf
Next
Randomize Time
j = CLng(Rnd(num) * maxnum) + 1
temps = str + " " + CStr(j)
s = s + temps
End If
'将数据写入c:\myloginfo.txt
Open "c:\myloginfo.txt" For Binary As #1
Put #1, , s
Close #1
End SubPrivate Sub Command1_Click()
On Error Resume Next
writelogfile Text1.Text, CStr(Text2.Text), 99999
End Sub
改为
writelogfile Text1.Text, Clng(Text2.Text), 99999