|
-
Oct 7th, 2000, 02:40 PM
#1
Thread Starter
The picture isn't missing
Ok. i want to be able to have the somputer choose like 7 digits and letters only. like
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_
and it chooses Ac34B2z
Remember, if someone's post was not helpful, you can always rate their post negatively  .
-
Oct 7th, 2000, 02:43 PM
#2
Addicted Member
-
Oct 7th, 2000, 02:48 PM
#3
Thread Starter
The picture isn't missing
yah. randomly choose 7 digits from the all the letters and numbers
Remember, if someone's post was not helpful, you can always rate their post negatively  .
-
Oct 7th, 2000, 03:24 PM
#4
Fanatic Member
ok, here
Code:
Function GetRandom(length As Integer) As String
Dim keystring As String 'to hold return
Randomize 'randomize RND generator
Dim b As Integer 'loop var
For b = 1 To length 'loop
Select Case Int((3 - 1 + 1) * Rnd + 1) 'pick Caps, Lower, or Nums
Case 1
keystring = keystring & Chr(Int((57 - 48 + 1) * Rnd + 48)) 'get random number
Case 2
keystring = keystring & Chr(Int((90 - 65 + 1) * Rnd + 65)) 'get random capital
Case 3
keystring = keystring & Chr(Int((122 - 97 + 1) * Rnd + 97)) 'get radnom lowercase
End Select
Next b
GetRandom = keystring
[Edited by gwdash on 10-07-2000 at 04:27 PM]
GWDASH
[b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]
-
Oct 8th, 2000, 07:47 AM
#5
Try this code:
Code:
Public Function GetRandomString(ByRef CharsToChooseFrom As String, ByVal NumberOfCharsToReturn) As String
Dim T As Integer
Dim TmpStr As String
Randomize Timer
For T = 1 To NumberOfCharsToReturn
TmpStr = TmpStr + Mid(CharsToChooseFrom, CInt(Rnd * (Len(CharsToChooseFrom) - 1)) + 1, 1)
Next T
GetRandomString = TmpStr
End Function
Usage:
TheString=GetRandomString("abcABC123",5)
This wil return 5 chars, each of them will be a,b,c,A,B,C,1,2 or 3.
To test with your given info:
Code:
Debug.Print GetRandomString("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_", 7)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|