Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default string parsing w/wildcard problem


Hi. So heres my problem: I read in lines of text from a text file an
place all of them in an array. I then trim off any extra space on th
right and left sides. There is one line that has quotes at th
beginning and end and will have a comma in the middle. I want to tak
everything to the left of the comma and place it in (1,1) of a
dimensional array then take everything to the right of the comma an
place it in (2,1) of the 2 dimensional array. My code is below.
stepped through it and when it gets to the if statement and the arra
value meets the requirements (ex. ""Somwhere, AB 12345"") it just jump
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 I
-------------------

--
neverend
-----------------------------------------------------------------------
neverends's Profile: http://www.excelforum.com/member.php...fo&userid=3504
View this thread: http://www.excelforum.com/showthread.php?threadid=54997

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default string parsing w/wildcard problem

A wild card can't be used (successfully) in an equality statement.

use LIKE instead:

If prelimarray(i) Like """*""" then


demo's from the immediate window:

s = """Somwhere, AB 12345"""
? s
"Somwhere, AB 12345"
? s like """*"""
True
s = "Somewhere "" ab, ef "" 12345"
? s
Somewhere " ab, ef " 12345
? s Like """*"""
False

--
Regards,
Tom Ogilvy


"neverends" wrote:


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
--------------------


--
neverends
------------------------------------------------------------------------
neverends's Profile: http://www.excelforum.com/member.php...o&userid=35045
View this thread: http://www.excelforum.com/showthread...hreadid=549971


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default string parsing w/wildcard problem


Thank you. I just replaced the "=" with "LIKE" and it worked perfectly.


--
neverends
------------------------------------------------------------------------
neverends's Profile: http://www.excelforum.com/member.php...o&userid=35045
View this thread: http://www.excelforum.com/showthread...hreadid=549971

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Parsing a string neverends Excel Programming 2 June 7th 06 05:38 PM
Parsing a string simonc Excel Programming 4 March 27th 06 08:04 AM
Need help parsing a string Daminc[_38_] Excel Programming 4 January 26th 06 11:53 AM
parsing a string Mark[_57_] Excel Programming 4 April 28th 05 04:42 PM
TypeLib Information Problem? Pass a Function's parameter names as string for parsing? Ali G Excel Programming 1 December 3rd 04 07:02 PM


All times are GMT +1. The time now is 03:02 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"