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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vbCrLf question 2

Status
Not open for further replies.

ktighe

Programmer
May 25, 2001
45
0
0
US
I'm trying to pull some information out of a huge memo field. I can find the start of the data I need by using Instr(...) and searching for a specific word that is always there. I'm having trouble finding the end of the data that I want, though. The data that I'm trying to pull out varies in length, but there is always a new line character after the data. Here's what I'm trying to do:

temp = InStr(start_of_my_data, memo_field, vbCrLf)
Mid(memo_field, start_of_my_data, temp - start_of_data)

For some reason, the InStr call always returns 0. I tried using vbLf instead, but that just finds the very end of the field. I also tried vbCr, but that returns a 0, too. Does anyone know why this is? Or, does anyone know an alternate way of finding the new line character position? Any help would be greatly appreciated!

Kevin
 
Well, there is an alternative I can suggest.

Try searching for chr(10) or chr(13) in your Instr statement.

Gary
gwinn7
 
The problem is VbCrLf is two characters, maybe you should write your own function to look for Chr(13) & Chr(10).

I would use code like:

instring=0
for pos=1 to len(memo_field)-1
if instring=0 and mid(memo_field,n,2)=(chr(13) & chr(10)) then instring=pos
next pos


This would make 'instring' equal to the first VbCrLf in the memo.

Andrew.
 
Thanks for your help! Haven't tried your suggestions yet, but I think that's exactly what I needed.

kevin
 
Worked like a charm! I used Chr(10) in my instr call. Kinda wierd, though: I tried using VbCr and VbLf, and neither of them returned what I wanted....

Kevin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top