Fast way to generate unique strings

From: R Avery (ravery74_at_yahoo.co.uk)
Date: 10/26/04


Date: Tue, 26 Oct 2004 11:58:38 -0400

what is the fastest VBA code to generate a list of random strings of a
specified length.

the function prototype i want is

sub GetUniqueStrings(Strings() as string, Length as long)

The one i had been using seems slow when using it to generate lots of
strings, and i was wondering if there was a way to speed it up. Thanks!

Public Function GetUniqueString(ByVal NumChars As Long) As String
     Dim i As Long, str As String

     GetUniqueString = Space$(NumChars)

     For i = 1 To NumChars
         Mid$(GetUniqueString, i, 1) = Chr(RandBetween(97, 122))
     Next i

End Function

Public Function RandBetween(ByVal LB As Long, ByVal UB As Long) As Long
     RandBetween = LB + Round(Rnd * (UB - LB), 0)
End Function



Relevant Pages

  • Re: Referring to slides from within a VB macro
    ... First step is to copy and paste the following macro into your Module. ... Sub NameShape() ... If you only have one shape and want both strings in it, ... The presenters name is used to fill a text box in the slideshow, ...
    (microsoft.public.powerpoint)
  • Re: Home Stretch! *
    ... Sub Replacer() ... Uses regular expressions For search To make sure found strings are ... Dim RgExp As Object ... 'If Selection = "" Then ...
    (microsoft.public.excel.programming)
  • Re: Concatenate without string or convert string to variable
    ... bit of code by calling a sub with two input numbers. ... Player As String) ... 'First read the Team and Player to reference TeamX_PlayerXScore ... 'as strings instead of as references to fields and text boxes. ...
    (microsoft.public.access.formscoding)
  • Re: Concatenate without string or convert string to variable
    ... bit of code by calling a sub with two input numbers. ... Player As String) ... 'First read the Team and Player to reference TeamX_PlayerXScore ... 'as strings instead of as references to fields and text boxes. ...
    (microsoft.public.access.formscoding)
  • RE: Validation-Combo Box
    ... cannot allow zero length strings. ... Private Sub cboStuff_NotInList ... See http://www.QBuilt.com for all your database needs. ... > on of the three dropdown items. ...
    (microsoft.public.access.forms)

Loading