|
-
Feb 9th, 2000, 10:10 PM
#1
Thread Starter
Hyperactive Member
I need to reverse a string, or at least read from the end of it. I need to check an entry in a CSV file and that enty is 8 from the end. So basically I need to reverse the string and use InStr() from the end (right side). THe CSV is pretty large so I can't read it from the front, it takes too long. Any suggestions?
------------------
'cos Buzby says so!'
-
Feb 9th, 2000, 10:14 PM
#2
-
Feb 9th, 2000, 10:17 PM
#3
Thread Starter
Hyperactive Member
That's what I first thought of but either I'm using it wrong or it doesn't work because using
strTemp = Right(strLine, len(strLine))
just makes strTemp = strLine. I need to set the lenght to the total length because I'm not sure how large the line is. There are memo fields and large text strings that can be empty or full. Would it make a difference if the len() was shorter than the entire string?
I told you that I had found a new tab line :-)
PS: The control is working great, thanks again!
------------------
'cos Buzby says so!'
-
Feb 9th, 2000, 10:31 PM
#4
Thread Starter
Hyperactive Member
I did a search in the Tips section and the only suggestion was to do this:
for lngTemp = len(strLine) to 1 step -1
strTemp = strtemp & mid(strLine, lngtemp,1)
next lngTemp
But this has to loop through the file (even if I changed the 'to 1' with len(strLine)/2 it will still require a fair amount of looping. I really want to avoid this because I have to check for everyline for this section and if it equals "Open", then I have to loop the entire line already once. This looping is already taking a long time.
------------------
'cos Buzby says so!'
-
Feb 9th, 2000, 11:30 PM
#5
The Right function uses two parameters, the source string the number of characters on the right end that you want to extract. So when you use len(strLine) in
strTemp = Right(strLine, len(strLine))
you are you saying that you want to extract the total length of the line and put it into strTemp.
Unless I totally misunderstand what you want to do, Buzby's original suggestion which was essentially
strTemp = Right(strLine, 8)
will extract the rightmost 8 characters regardless how long the line is.
------------------
Marty
What did the fish say when it hit the concrete wall?
> > > > > "Dam!"
-
Feb 9th, 2000, 11:44 PM
#6
Thread Starter
Hyperactive Member
I guess I wasn't clear in my original post. I want to grab the right most chars but I need to get them reversed somehow. Basically I need to go 8 fields in from the right in a 32 field line from a CSV file. The 8th field tells me whether to write this line into the Database Table or to skip it. I can't go from the front because the line's can get rather long. Any suggestions to do this would be great.
------------------
'cos Buzby says so!'
-
Feb 10th, 2000, 01:02 AM
#7
netSurfer,
Combine the two functions here:
strTemp2 = Right(strLine,8)
for lngTemp = 1 to 8
strTemp = mid(strTemp2, lngtemp,1) & strTemp
next lngTemp
Hope this helps
------------------
Boothman
There is a war out there, and it is about who controls the information, it's all about the information.
-
Feb 10th, 2000, 01:10 AM
#8
Thread Starter
Hyperactive Member
Boothman, that still leaves me with the problem of having to loop through it to the pot I need and since I'm not sure exactly where it is, it makes it more difficult. I sorta gave up and just used the loop (very similar to what you did except counted from 8 to 1) and it works, it's just a little slower than I like. Oh well.
Thanks for the help everyone.
------------------
'cos Buzby says so!'
-
Feb 10th, 2000, 01:18 AM
#9
Thread Starter
Hyperactive Member
For the curious:
I decided to use the VS View FlexGrid. IT will automatically load CSV files and it's alot easier checking cell values at the end :-) I decided that the cost of it offsets the pain in the a$@ of writing the code and the amount of time it takes to do manually. Thanks again.
------------------
'cos Buzby says so!'
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
|