|
-
Oct 31st, 1999, 10:07 AM
#1
Thread Starter
New Member
The code below is my check for a letter through a textbox array...it doesnt seem to work since it has a type mismatch at the points with ***
Thanx in advance.
Dim i As Integer
i = 0
Dim letterCheck(2) As Integer
Dim searchStr As String
searchStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
For i = 0 To 2
letterCheck(i) = InStr(txtValues(i), searchStr)
If letterCheck(i) = Not (0) Then
Answer = "LETTER"
txtValues(i).Text = ""
Exit For
End If
Next i
*** a = txtValues(0)
*** b = txtValues(1)
*** c = txtValues(2)
-
Oct 31st, 1999, 05:43 PM
#2
Addicted Member
You can check character code with Asc() function.
For sample:
If (Asc(your_char)>=65 and Asc(your_char)<=90) or (Asc(your_char)>=97 and Asc(your_char)<=122) Then Answer="LETTER"
------------------
smalig
[email protected]
smalig.tripod.com
-
Nov 1st, 1999, 05:20 AM
#3
Thread Starter
New Member
thank you but that doesnt help me much if the code i have doesnt work...is there something wrong with the InStr command..
-
Nov 1st, 1999, 05:52 AM
#4
New Member
I could be mistaking but you have:
Dim searchStr As String
in you code. You're using searchStr as an array. You'll probably have to say something like this.
Dim searchStr() As String
You're treating a string like an array. Strings don't have elements. That probably why you're getting errors on the lines that say searchStr(0), searchStr(0), etc. Well, hope that helped....
-
Nov 1st, 1999, 05:54 AM
#5
New Member
Sorry, I looked at txtValues(0) and was thinking you put searchStr(0). I'm not too sure what the problem is now because I don't see how txtValues() is defined. Sorry for the error.
-
Nov 1st, 1999, 05:55 AM
#6
Are you attempting to determine one by one if the characters in a textbox are alphabetic? Is txtValues() a textbox control array? If so then your code has a basic problem in that txtValues(i) will contain the complete text that the user enters in the textbox and not just one character and your comparison will in all likelyhood never be true. To get at one character you need to do something like Mid(txtValues(i), StartPosition, 1) where you would increment StartPos from 1 to Len(txtValues(i)). Also I believe what smalig was trying to show you was that you don't need to build your own compare string (abcde....etc) like you did, because there are features built into VB to do it for you. Finally, you did not show a, b and c Dim'ed in your code. When I Dim'ed them as Strings I got no errors.
------------------
Marty
-
Nov 1st, 1999, 06:59 AM
#7
Thread Starter
New Member
txtValues() is a textbox control array of 3 elements....
i want to check through all three elements separately or together for ANYTHING other than a number...for now....checking for letters is fine..
If txtValues(i) contains only one character...how would teh check occur if the user typed "2b" in txtValues(0)
i hope this clears it up...not sure though 
a, b, and c are single type since i need them in a calculation..
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
|