/images/2011/147787/2011051411021524.jpg" border="0" />
??不可能吧,把你的验证程序代码发上来看看
For k = 1 To 16
intTmp = Rnd * 1000 Mod 61 + 1
Print #1, Mid(strALl, intTmp, 1);
Next k
再加上后面的一次不就是写了17次文件吗?
'下面是主要的代码:
Private Sub CreatFile(Optional ByVal L As Long = 10000)
Dim PathName As String, ID(5) As Byte, IDS(21) As Byte, K As Byte
Dim I As Long, File1 As Long, File2 As Long, RndTime As Byte
Dim StartTime As Date, Flag1 As Boolean, Flag2 As Boolean, Flag3 As Boolean
On Error Resume Next
If L < 1 Then Exit Sub
PathName = App.Path
PathName = PathName & IIf(Right(PathName, 1) = "\", "NumSTRS.Ron", "\NumSTRS.Ron")
File1 = FreeFile
Open PathName For Binary As #File1
Get #File1, 1, ID
For I = 0 To 5
File2 = File2 Or ID(I)
Next
If File2 = 0 Then
ID(0) = 73
ID(1) = 108
ID(2) = 97
ID(3) = 104
ID(4) = 105
ID(5) = 99
End If
File2 = FreeFile
PathName = App.Path
I = 1
PathName = IIf(Right(App.Path, 1) = "\", App.Path, App.Path & "\") & "RNGSTR"
Do While Len(Dir(PathName & Trim(Str(I)) & ".TXT", vbHidden Or vbReadOnly Or vbSystem))
I = I + 1
Loop
PathName = PathName & Trim(Str(I)) & ".TXT"
Open PathName For Binary As #File2
IDS(18) = 48
IDS(19) = 48
IDS(16) = 35
IDS(20) = 13
IDS(21) = 10
Do While RndTime = 0
RndTime = CLng(Timer) Mod 26
Loop
StartTime = Now
For I = 0 To L
K = I Mod 10
If K Mod 5 = 0 Then
IDS(17) = 53
ElseIf K Mod 3 = 0 Then
IDS(17) = 50
Else
IDS(17) = 49
End If
For K = 0 To 5
ID(K) = Add1(ID(K), K * 2 + 1)
Next
Flag1 = False
Flag2 = False
Flag3 = False
For K = 0 To 15
IDS(K) = RNDChar((I And &HFF&) Xor ID(K Mod 6), (I Mod 23) + RndTime Xor K)
Flag1 = Flag1 Or ((IDS(K) > &H2F) And (IDS(K) < &H3A))
Flag2 = Flag2 Or ((IDS(K) > &H40) And (IDS(K) < &H5B))
Flag3 = Flag3 Or ((IDS(K) > &H60) And (IDS(K) < &H7B))
Next
Do While Not Flag1
IDS(13) = (IDS(13) Mod 10) + &H30
Flag1 = (IDS(13) > &H2F) And (IDS(13) < &H3A)
Loop
Do While Not Flag2
IDS(3) = IDS(3) Mod 20 + &H41
Flag2 = (IDS(3) > &H40) And (IDS(3) < &H5B)
Loop
Do While Not Flag3
IDS(10) = IDS(10) Mod 20 + &H61
Flag3 = (IDS(10) > &H60) And (IDS(10) < &H7B)
Loop
IDS(2) = ID(0)
IDS(4) = ID(1)
IDS(8) = ID(2)
IDS(11) = ID(3)
IDS(12) = ID(4)
IDS(14) = ID(5)
Put #File2, , IDS
Next
Close File2
Put #File1, 1, ID
Close File1
MsgBox "生成随机字符串成功!生成文件名为:" & PathName & " 请查看。" & vbCrLf & _
"共生成了" & I - 1 & "条字符串,共计耗时" & DateDiff("S", StartTime, Now) & "秒。" _
, vbInformation Or vbOKOnly, Me.Caption
End Sub
Private Function RNDChar(ByVal Num1 As Byte, Optional ByVal RNDNum As Long) As Byte
Dim I As Long
Static K As Long
If RNDNum = 0 Then RNDNum = CLng(Timer) Mod 256
I = RNDNum + Num1
If (I < 48) Or (I > 122) Or ((I > 57) And (I < 65)) Or ((I > 90) And (I < 97)) Or I = K Then
If I < 48 Then
I = Add1(I + Rnd * 17, CLng(Timer) And &HFF&)
Else
I = Add1(I)
End If
End If
K = I
RNDChar = I
End Function
Private Function Add1(ByVal Num1 As Byte, Optional ByVal AddNum As Long) As Byte
Dim I As Integer
I = (Num1 + AddNum) And &HFF&
AddStart:
If ((I > &H2F) And (I < &H3A)) Or ((I > &H40) And (I < &H5B)) Or ((I > &H60) And (I < &H7B)) Then
Add1 = I: Exit Function
ElseIf I > 122 Then
I = I - 74: GoTo AddStart
ElseIf I > 90 Then
Add1 = I + 6: Exit Function
ElseIf I > 57 Then
Add1 = I + 7: Exit Function
Else
Add1 = 48: Exit Function
End If
End Function
我刚才重启机器了,一个哥们向我要VFP的图书馆管理系统代码,我去找了,没找到,谁能帮我呀
我的代码就简单了,看吧:
Option Explicit
Const MAX100 = 5
Const MAX200 = 3
Const MAX500 = 2
Private Sub Form_Load()
Dim strTime As String, strALl As String
strTime = Time()
Dim i As Integer, j As Integer, k As Integer
Dim intTmp As Integer, intLenSTRALL As Integer
Dim cnt100 As Integer, cnt200 As Integer, cnt500 As Integer
strALl = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
Randomize Time
intLenSTRALL = Len(strALl)
Dim strTmp As String
Open App.Path & "\Test.txt" For Output As #1
For i = 1 To 1000
cnt100 = 0: cnt200 = 0: cnt500 = 0
For j = 1 To 10
For k = 1 To 16
intTmp = Rnd * 1000 Mod 61 + 1
Print #1, Mid(strALl, intTmp, 1);
Next k
intTmp = intTmp Mod 10
If (intTmp Mod 2 = 0) And cnt100 < MAX100 Then
Print #1, "#100": cnt100 = cnt100 + 1
ElseIf (intTmp Mod 4 = 1) And cnt200 < MAX200 Then
Print #1, "#200": cnt200 = cnt200 + 1
ElseIf (intTmp Mod 4 = 3) And cnt500 < MAX500 Then
Print #1, "#500": cnt500 = cnt500 + 1
ElseIf (MAX100 - cnt100) > (MAX200 - cnt200) And cnt100 < MAX100 Then
Print #1, "#100": cnt100 = cnt100 + 1
ElseIf (MAX200 - cnt200) > (MAX500 - cnt500) And cnt200 < MAX200 Then
Print #1, "#200": cnt200 = cnt200 + 1
ElseIf (MAX500 - cnt500) > (MAX100 - cnt100) And cnt500 < MAX500 Then
Print #1, "#500": cnt500 = cnt500 + 1
ElseIf (cnt100 < MAX100) Then
Print #1, "#100": cnt100 = cnt100 + 1
ElseIf (cnt200 < MAX200) Then
Print #1, "#200": cnt200 = cnt200 + 1
ElseIf (cnt500 < MAX500) Then
Print #1, "#500": cnt500 = cnt500 + 1
End If
Next j
Next i
Close #1
MsgBox strTime & "-" & Time()
End
End Sub
For k = 1 To 16
intTmp = Rnd * 1000 Mod 62 + 1
Print #1, Mid(strALl, intTmp, 1);
Next k
是不是应该除62?
顺便说句,帅哥你太有才了:)
Collection是一个集合
如果一个集合{1,2,3,4,5,6}
这里有6个元素.
那么它的count就是6
之后我就随机它的count,之后取出这个count的元素.之后就delete了这个count的元素
那么Collection就少了一个元素,就少了一个count,那么又在余下的count进行随机,,,,
依此类推...