1

I have a text file with multiple different items that I need to grab from it.

Here is portion of the text file:

JOB_NUMBER                      XXXX-XX              TYPE: String               
                                                     SOURCE: User-Defined       
                                                     ACCESS: Full               
                                                     DESIGNATED: NO             
                                                     DESCRIPTION:               

CUSTOMER                        SAMPLE COMPANY       TYPE: String               
                                                     SOURCE: User-Defined       
                                                     ACCESS: Full               
                                                     DESIGNATED: NO             
                                                     DESCRIPTION:               

OVERBURN                        5.500000e-03         TYPE: Real Number          
                                                     SOURCE: User-Defined       
                                                     ACCESS: Full               
                                                     DESIGNATED: NO             
                                                     DESCRIPTION: 

I need to find the string with JOB_NUMBER in it and grab the number "XXXX-XX" same with "CUSTOMER" but that will be a string not an integer.

This cannot be done by line number because it will be different every time.

Any suggestions would be very helpful

3 Answers 3

1

You should also look at here.

Another example

Sign up to request clarification or add additional context in comments.

Comments

1

Is there only going to be 1 job number and one customer string in each file? If yes you could read the file to a string and extract like so:

Dim thefile As String = IO.File.ReadAllText("C:\test.txt")
Dim jobnumber As String = Split(Split(thefile, "JOB_NUMBER")(1), "TYPE:")(0).Trim()
Dim customer As String = Split(Split(thefile, "CUSTOMER")(1), "TYPE:")(0).Trim()

Comments

0

If those are fixed width columns, simply find the lines that begin with JOB_NUMBER and CUSTOMER and substring out the middle column, then trim the spaces.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.