|
-
Mar 6th, 2002, 10:13 PM
#1
Thread Starter
Hyperactive Member
Optimize this!!!!
There must be a way to optimize this code:
VB Code:
If strTempo = "a" Or strTempo = "b" Or strTempo _
= "c" Or strTempo = "d" Or strTempo = "e" _
Or strTempo = "f" Or strTempo = "g" Or strTempo _
= "h" Or strTempo = "i" Or strTempo = "j" Or _
strTempo = "k" Or strTempo = "l" Or strTempo = "m" _
Or strTempo = "n" Or strTempo = "o" Or strTempo _
= "p" Or strTempo = "q" Or strTempo = "r" Or _
strTempo = "s" Or strTempo = "t" Or strTempo = _
"u" Or strTempo = "v" Or strTempo = "w" Or _
strTempo = "x" Or strTempo = "y" _
Or strTempo = "z" Or strTempo = "A" Or strTempo = "B" Or strTempo _
= "C" Or strTempo = "D" Or strTempo = "E" _
Or strTempo = "F" Or strTempo = "G" Or strTempo _
= "H" Or strTempo = "I" Or strTempo = "J" Or _
strTempo = "K" Or strTempo = "L" Or strTempo = "M" _
Or strTempo = "N" Or strTempo = "O" Or strTempo _
= "P" Or strTempo = "Q" Or strTempo = "R" Or _
strTempo = "S" Or strTempo = "T" Or strTempo = _
"U" Or strTempo = "V" Or strTempo = "W" Or _
strTempo = "X" Or strTempo = "Y" _
Or strTempo = "Z" Then
TrouverProchainAlpha = i - 1
Exit Function
End If
Please help me!
-
Mar 6th, 2002, 10:19 PM
#2
try...
VB Code:
If strTempo Like "[A-Z]" Or strTempo Like "[a-z]" Then
'...
End If
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Mar 6th, 2002, 10:22 PM
#3
Little slow on the trigger
VB Code:
If strTempo Like "[A-Z]" Or strTempo Like "[a-z]" Then MsgBox "ALPHA!"
EDIT: or you could use crptcbalde's code.
-
Mar 6th, 2002, 10:26 PM
#4
Need-a-life Member
Another way...
VB Code:
If ASC(Ucase$(strTempo)) >= A AND ASC(Ucase$(strTempo)) <= 90 Then
TrouverProchainAlpha = i - 1
Exit Function
End If
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
-
Mar 6th, 2002, 10:30 PM
#5
Thread Starter
Hyperactive Member
-
Mar 6th, 2002, 10:32 PM
#6
ASC(Ucase$(strTempo)) >= A
Well, I see where you were going anyway.
-
Mar 6th, 2002, 10:36 PM
#7
Need-a-life Member
Sorry.... I was still pressing the Alt-Key (to check the number)
VB Code:
If ASC(Ucase$(strTempo)) >= 65 AND ASC(Ucase$(strTempo)) <= 90 Then
TrouverProchainAlpha = i - 1
Exit Function
End If
or
VB Code:
If UCase$(strTempo) >= "A" And UCase$(strTempo) <= "Z" Then
TrouverProchainAlpha = i - 1
Exit Function
End If
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
-
Mar 7th, 2002, 12:44 AM
#8
Fanatic Member
Use constants: vbKeyA, vbKeyZ.
Store Asc(UCase$(strTemp) in a variable so you don't have to Asc and UCase$ it twice.
VB Code:
Dim charCode As Integer
charCode = Asc(UCase$(strTempo))
If vbKeyA <= charCode And charCode <= vbKeyZ Then
TrouverProchainAlpha = i - 1
Exit Sub
End If
By the way, don't ever code like you did when asking the question--checkerboard patterns are not for code . If you ever need to check a ton of values like that, line up the code more neatly.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|