Results 1 to 8 of 8

Thread: Random String function

  1. #1

    Thread Starter
    Hyperactive Member FATBOYPEE's Avatar
    Join Date
    May 2001
    Location
    Charleville (Ireland) Still. ANYONE GOT A JOB I CAN HAVE ? GIZA JOB. I CAN DO THAT....
    Posts
    463

    Random String function

    Hey guys..

    Anyone got a bit of code/solution to getting a unique character string ??

    No numerics or control chars allowed & I'm unable to keep track of the chars used in a particular order ?

    Bit like rnd but for strings ??

    Pee

    Best Bar.....

  2. #2
    Frenzied Member
    Join Date
    Sep 1999
    Location
    Phoenix, az
    Posts
    1,517
    Let me whip up some code for ya...brb

  3. #3
    Frenzied Member
    Join Date
    Sep 1999
    Location
    Phoenix, az
    Posts
    1,517

    Here ya go

    Code:
    Public Function GetRanString(ByVal iChars As Integer)
        Dim x As Integer
        Dim intRand As Integer
        Dim strOut As String
        Dim GotRand As Boolean
        Randomize
    
    
        For x = 1 To iChars
    
    
            Do Until GotRand = True
                intRand = Int((90 - 48 + 1) * Rnd + 48)
    
    
                If InStr(1, "ABCDEFGH JK MN PQRSTUVWXYZ 23456789", Chr(intRand), 1) Then
                    GotRand = True
                End If
            Loop
            strOut = strOut & Chr(intRand)
            GotRand = False
        Next
        GetPassword = strOut
    End Function

  4. #4
    jim mcnamara
    Guest
    Code:
    function rndstr(iLen as integer ) as string
    Dim i,str
    Dim t as string
    t="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    str=""
    for i=1 to iLen
       str = str & mid(t, Rnd*26 +1,1)
    next
    rndstr = str
    end functionm
    usage

    myrandomstring = rndstr(10) ' gives 10 chars back

  5. #5
    Frenzied Member
    Join Date
    Sep 1999
    Location
    Phoenix, az
    Posts
    1,517
    Was that what you wanted?

  6. #6
    Hyperactive Member
    Join Date
    Aug 2001
    Location
    The Dark Side of the Moon
    Posts
    448
    My sequential spamming has been interupted!

    I like the quote, and LOL thing too. Whaha clever, that's like a free post too!

  7. #7
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    To JaredM and Evan

    I moved this thread to Chit Chat.

    Please stop posting garbage in the General Vb forum just to up your counts. I don't want to have to take take more serious action then this warning.

  8. #8
    PowerPoster MidgetsBro's Avatar
    Join Date
    Oct 2000
    Location
    Apparently, Internet.com
    Posts
    3,125

    Re: To JaredM and Evan

    Originally posted by MartinLiss
    I moved this thread to Chit Chat.

    Please stop posting garbage in the General Vb forum just to up your counts. I don't want to have to take take more serious action then this warning.
    Told you guys!!!
    <removed by admin>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width