Results 1 to 3 of 3

Thread: Random letters?

  1. #1

    Thread Starter
    Member mafia_geek's Avatar
    Join Date
    Jan 2002
    Location
    California
    Posts
    45

    Random letters?

    is there a way to generate random letters in vb?

    i did it by assigning each letter to a number (1=a, 2=b...) but i want to know if there's an easier way
    -mafia_geek-

    Condito, Ergo Sum

  2. #2
    Addicted Member Pickler's Avatar
    Join Date
    May 2001
    Location
    nffanb
    Posts
    248
    You could do the following.

    VB Code:
    1. Dim Letter As Integer
    2.  
    3. Randomize
    4.  
    5. Letter = Int((26 * Rnd) + 65)
    6. Text1 = Chr$(Letter)

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    VB Code:
    1. Private Sub Command1_Click()
    2. Dim RanLetter As String
    3. Dim Position As Integer
    4. RanLetter = "abcdefghijklmnopqrstuvwxz"
    5. Randomize
    6. Position = CInt(Rnd() * 25) + 1
    7. Text1.Text = Mid(UCase(RanLetter), Position, 1)
    8. End Sub

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