I am now maintaining a legacy VBA/Access 2000 application for a client. They have a customer who emails orders with text that looks like this
Contact: Peggy Hill
Company: Arlen Residential Mortgage Finance Co
Address: 43456 South 18939 West, Suite 47995
City: Arlen City
ContactState: TX
ContactZip: 88888
Phone: 8019990000
Email: [email protected]
DateOrdered: 4/6/09
DateDue: 4/15/09
etc...
The application has a VBA class with all of attributes but no way to parse the data into the appropriate fields. My client wants a form into which they can paste the text out of the email, have it parse to fields for verification and then write to the db.
Issues/Facts:
- Each value is set off with 'ValueName: " token
- Depending on how the email clients mangle the string there may or may not be a CrLf at the end of each line.
- Missing values will have just the token, no "" or empty space.
I'd like to create a CreateOrder(OrderText As String)
function that would read the text from the form but I have no idea how to handle the parsing in VBA.
I started creating a 2D array with the tokens pre-entered, but that seems clunky since I have to read the next item in the array to figure out when to stop accepting data for the previous token.
Suggestions?