Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String parsing problem

Status
Not open for further replies.

NeverEnds

Programmer
Mar 19, 2006
5
US
Hi. So heres my problem: I read in lines of text from a text file and place all of them in an array. I then trim off any extra space on the right and left sides. There is one line that has quotes at the beginning and end and will have a comma in the middle. I want to take everything to the left of the comma and place it in (1,1) of a 2 dimensional array then take everything to the right of the comma and place it in (2,1) of the 2 dimensional array. My code is below. I stepped through it and when it gets to the if statement and the array value meets the requirements (ex. ""Somwhere, AB 12345"") it just jumps to the end if. Can anyone help? Thanks in advance.

Code:
quotes = """" & "*" & """"

If prelimarray(i) = quotes Then
            counter2 = 1
            For p = 0 To counter
                If prelimarray(i) <> "" Then
                counter2 = counter2 + 1
                indexposition = InStr(1, prelimarray(i), ",") + 1
                arrayofstrings(1, counter2) = Left(prelimarray(i), InStr(1, prelimarray(i), ","))
                arrayofstrings(2, counter2) = Mid(prelimarray(i), indexposition, Len(prelimarray(i)))
                arrayofstrings(1, counter2) = LTrim(arrayofstrings(1, counter2))
                End If
            
            Next p
        End If
 


Hi,

Check out the Split Function.

Skip,

[glasses] [red]Be Advised![/red] The only distinction between a bird with one wing and a bird with two, is merely...
a difference of A Pinion! [tongue]
 
You're probably confusing the interpreter with all those quotes. Maybe it would work if you used Chr(34) instead, as in:
Code:
quotes = Chr(34) & Chr(34) & * & Chr(34) & Chr(34)

_________________
Bob Rashkin
 
Thanks for all your replies. I ended up just using LIKE and it worked.

I replaced
If prelimarray(i) = quotes Then

with
If prelimarray(i) Like quotes Then

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top