extracting data

G

Guest

I am using the following routine to extract data from email(web form) form.
The routine works great for single fields however if a field in the webform
is a memo box. it doesnt work for that field. I believe its because there are
multiple CHR(13) between the fields. For Example the email I get looks like
this:

First name: xxxx
last name: xxx
comments:

xxx this is where comments start.
xxxx and continue
xxxx and continue

Can someone take a look at this sniplet and tell me what is the best way to
correct this? Code follows:

Public Function ExtractDetail(textLine As Variant, FormItemReq As String) As
Variant

Dim StartLine As Variant, EndLine As Variant, ExtractText As Variant

StartLine = InStr(textLine, FormItemReq)
If StartLine > 0 Then

StartLine = StartLine + Len(FormItemReq)
EndLine = InStr(StartLine, textLine, Chr(13))
ExtractText = Mid(textLine, StartLine, EndLine - StartLine)

End If
If Len(ExtractText) = 0 Then ExtractText = ""

ExtractDetail = Trim(ExtractText)

End Function


Thanks, Jack
 
A

Alex Dybenko

Hi Jack,
try something like this
get start of comments:
StartLine = InStr(textLine, "comments:")

get rest of message:

strCommnents=mid(textLine, StartLine +10)

replace CHR(13) with space

strCommnents=replace(strCommnents,CHR(13)," ")

HTH
 
G

Guest

Alex,
Thank you so much for the quick reply. Your solution would work if i had
only one memo box (comments). For some reason in frontpage form it wants to
place the memo box fields at the end. I apoligize for not giving enough
details.

here is a sample of the email i get:
first name: joe
last name: blow

comments: <------------notice how the memo fields automatically drop
chr(13)after the single fields.----------------

here is where comments actual start
second line of comments.

other_details:

here is where second memo starts
second line goes here.

I have tried replacing chr(13) in numerious places within code without a
positive result. As I mentioned before, the single fields work great. Its
only where there are 2 chr(13) between the field name and field value inside
of the email.
The form / email that comes in is in formatted text. I have tried to change
it to comma delimited but then I believe there would be problem if all fields
were not filled in.

Any further assistance / expertise you could provide would be greatly
appreciated.

Thank you,
Jack
 
A

Alex Dybenko

Hi,
then you have to get a position of other_details, then get a length of
comment data and then get it using same mid, but also supplying length
HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top