Results 1 to 3 of 3

Thread: alphanumeric random string generation in vb6

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2006

    Question alphanumeric random string generation in vb6

    Dear All,
    I jsut have this problem,

    I've to develop an alphanumeric string of length 4, which may contain a-z, 0-9, and only @. like 12sd, @1fg, so on..

    I've to generate a minimum of 50 characters at one click of create button, and have to display only when the display button is clicked , til lthen the strings have to be in clipboard ready to be pasted anywhere.

    once I close the application or load it for the first time, the clipboard should contain the last data.

    any idea guys

  2. #2
    Addicted Member
    Join Date
    Feb 2006
    Hyderabad, India

    Re: alphanumeric random string generation in vb6

    I am assuming you have the code to generate the strings.
    After creating the strings , write to the clipboard

    VB Code:
    1. clipboard.settext "your text here"

    To get the clipboard contents

    VB Code:
    1. text1.text=clipboard.gettext()
    In the formunload event write the clipboardtext to a textfile.
    In the foremload event get the text from the textfile.

  3. #3
    Hyperactive Member
    Join Date
    Oct 2005

    Re: alphanumeric random string generation in vb6

    VB Code:
    1. Private Sub Form_Load()
    2.     Debug.Print RandomString(9)
    3.     Debug.Print RandomString(9)
    4. End Sub
    5. Function RandomString(Length As Integer) As String
    6.     Dim i As Integer
    7.     Do While i < Length
    8.         Randomize
    9.         Select Case IIf(i = 0, Int(1 * Rnd + 1), Int(2 * Rnd))
    10.             Case 0: RandomString = RandomString & Chr(Int(10 * Rnd + 48))
    11.             Case 1: RandomString = RandomString & Chr(Int(26 * Rnd + 65))
    12.         End Select
    13.         i = i + 1
    14.     Loop
    15. End Function
    Should be easy enough to make it use a-z and not A-Z, could use Lower(RandomString(4)) even if you dont get RandomString(). Should be able to modify in '@' effortlessly also.

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