-
I know this is going to seem like an easy question, but I can't find the right syntax to handle it!
I have a string...
mystring = 10,11,12
and I am looping through a set of numbers i = 1-20
In the loop I compare i to mystring, and if the number in mystring is equal to i then I mark the check box as selected.
My problem is when I say Instr(mystring,i) and i=1 (for example) it is true because there is a 1 in the string, but it's not the truth I want because it's not 10,11,or 12.
I think I did a bad job of explaining that but if anyone has every handled this situation it would really help me out!
-
if your string has commas in it like that then you could do. Make sure the string starts with a comma though.
Code:
Instr(myString, "," & i & ",")
-
If you have VB6 then use the Split fuction to break up the string into it's numbers and then compare i with the entries in the array that Split creates. If you don't have VB6 then build an array by examining the characters in the string one by one. If you need help with either approach let me know.
-
Thank You,Iain17 !! That was exactly what I needed!
-
If you are going to do it that way then you also need to end your string with a comma or else (in your example) you would not be able to find ,12,.