Click to See Complete Forum and Search --> : Looping


cloud311
July 25th, 2000, 12:28 PM
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.

Rippin
July 25th, 2000, 02:31 PM
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

cloud311
July 25th, 2000, 05:49 PM
Thank you so much! This'll cut my code into about half!