Question Read/Search tab delimited text file

Nessie

Member
Joined
Oct 14, 2011
Messages
20
Programming Experience
1-3
Hi All,

Wondering if anyone can point me in the right direction.. I have looked at various snippets but nothing seems to be what I need.

I have a tab delimited text file in the form of:

Title: Ms
Forename: Fred
Middle Name Initials:
Surname: Bloggs
Employment Type: Permanent
Employee Number: 9089765
Primary Telephone Number: +44 (131) 456 7890
Secondary Phone Number:
Fax Number: +44 (131) 123 4567
Email Address: your.name@gmail.com
Job Title: business assistant
Company: The City of Anywhere
Department: Children & Families
Division: Directorate
Section: Business Support

I want to read the file and import specific details in to textboxes.

i.e
Forename:
Surname:
Employee Number:

etc, etc

The idea is once I have all the details to export to excel then use a VBScript to create an AD account.

Many thanks inadvance.
 
You can use the TextFieldParser class, to insert a standard code snippet using this class write (in a procedure) filParseText and press TAB.
You can of course also do a basic loop through File.ReadAllLines and use String.Split method.
 
Hi,

Managed to get somewhere using a dictionary but now struggling to get data into the textboxes.

Private Sub ButRead_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButRead.Click

Dim sr As New StreamReader("C:\UserDetails.txt")
Dim openWith As New Dictionary(Of String, String)

Do While sr.Peek <> -1
Dim line As String() = sr.ReadLine().Split(":")
openWith.Add(line(0), line(1))
Loop

TxtForename.Text = openWith.ContainsKey("Forename")
TxtSurname.Text = openWith.ContainsKey("Surname")

End Sub

All I am getting is 'true' in the textboxes but what I need is Fred Bloggs respectively.

Any help you be greatly appreciated..
 
Back
Top