Finding and parseing text (1 Viewer)

NauticalGent

Ignore List Poster Boy
Local time
Today, 12:53
Joined
Apr 27, 2015
Messages
6,281
Good morning Access Commandos,

Having a little difficulty getting something sorted out, hoping to find some assistance.

I have a table that is linked to an OutLook folder. The folder contains formatted messages.

Depending on the circumstances, the message structure varies as far as lines of info but one constant is that each line will begin with a key word, contain data elements, and end with a literal "//". For example:

ID/Critical/Initial/16025/EIC:R51000/3//

The line number varies which makes it hard for me to write simple code. What I need is a function that finds the line that starts with "ID" and assign everything from ID to "//" to a string that I can parse.

I am familiar with the Split() function and know how to use the resulting Array to populate the fields...it is assigning the string/variable I am having trouble with.

I found some examples using the InStr() function to find the initial criteria, but I cant find anything that tells me how to start from there, find the next "//" and assign everything in between to a string.

I came across RegExp it appears to be something I can use but I am not sure...AND the whole pattern thing is beyond my feeble brain.

Any help on this would be fantastic
 

static

Registered User.
Local time
Today, 16:53
Joined
Nov 2, 2015
Messages
823
Code:
Sub eg()
    
    s = "xxxxxxxxID/Critical/Initial/16025/EIC:R51000/3//yyyyyyyy"
    
    istart = InStr(1, s, "id/", vbTextCompare)
    iend = InStr(istart, s, "//", vbTextCompare)

    s = Mid(s, istart, iend - istart)
    
    arr = Split(s, "/")
    
    For Each s In arr
        Debug.Print s
    Next
    
End Sub
 

NauticalGent

Ignore List Poster Boy
Local time
Today, 12:53
Joined
Apr 27, 2015
Messages
6,281
Nailed it, grazie mille!
 

Users who are viewing this thread

Top Bottom