-
Hi, i have a string of 150 characters
I need to process each character 1 by 1..
And *ONLY* the 150 from the string..
so if there are 151 in the string.. then DON'T process any above 150
i need to process each character 1 by 1.. so its like
the character can be A-Z, 1-9, or any character that is like ®©žó.. ETC.
and i need to see what character it is on so far..
so if i is on character 15, then some variable will
= 15..
that way i can use it in other ways.
Code:
dim ProChar as <What ever it needs to>
prochar = first character
if prochar= "a" then
'do stuff'
end if
prochar = second character
if prochar= "a" then
'do stuff'
end if
Thanks.. ALOT
-
You need to use arrays and some string manipulation functions to achieve this, here is some code
Code:
Dim str as String ' variable holding string of characters
Dim characters(0 to 149) as String
'................CODE to fill str variable
For i = 0 To 149
characters(i) = Mid(str, i + 1, 1) ' get next character in string
Debug.Print characters(i) ' print characters
Next i
Then you would implement it into your code like this
Code:
prochar = characters(1)
if prochar = "a" then
'do stuff
end if
prochar = characters(2)
if prochar = "a" then
'do stuff
end if
' SO ON
-
Quote:
Originally posted by YoungBuck
Code:
prochar = characters(1)
if prochar = "a" then
'do stuff
end if
prochar = characters(2)
if prochar = "a" then
'do stuff
end if
' SO ON
It's better to do something like this:
Code:
'loop trough all the chars
For i = LBound(characters) To UBound(characters)
'get the char
prochar = character(i)
'do something with it
If prochar = "a" Then
'do something
End if
Next
-
Yeah I was just implementing the use of the array in the code that progeix had provided...........
-
Thnanks Guys, I think I can finish my program soon.
And implement new features.
Thanks for the quick response..