CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Looping

  1. #1
    Join Date
    Jun 2000
    Posts
    41

    Looping

    Hi, I'm having trouble creating this program. What it does is let you change your name in a certain game. What I need is a loop, that will check each variable holding a letter, against the whole alphabet, Uppercase and Lowercase, and depending on what letter is used, assign a variable a certain number. I'm pretty sure this is possible. The reason I want this is that I don't want one Big Select Case statement to check each letter-holding variable. Such As

    Select Case Letter1
    Case "A": SaveLetter1 = 154
    Case "B": SaveLetter1 = 155

    and so on. If you need me to clear this up, ask me and I'll try my best. If you can help, I'd appreciate it.





  2. #2
    Join Date
    Dec 1999
    Location
    Texas
    Posts
    96

    Re: Looping

    You could do something like the following to create a dynamic array to hold the ascii value of each letter.

    The ascii codes for letters A-Z are 65-90 respectively and the codes for letters a-z are 97-122 respectively. Hope this is helpful

    dim letters() as long
    dim str as string
    dim i as integer
    '
    str = "This is a test string"
    redim letters(1 to len(str)) as long
    '
    for i = 1 to len(str)
    letters(i) = Asc(mid$(str, i, 1))
    next i



    Rippin


  3. #3
    Join Date
    Jun 2000
    Posts
    41

    Re: Looping

    Thank you so much! This'll cut my code into about half!


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

Featured