Bigbadborris
Active member
- Joined
- Aug 21, 2013
- Messages
- 35
- Programming Experience
- Beginner
Hi all
I have the follow peice of code which reads customer data from a text file, it then extracts the data in the Customer Name and email address fields. If the email address contains the @ symbol it writes the Customer Name and the email Address in to another text file. or at least its supposed to!!!
Problem I am having is that it only writes the email address to the file, not the customer name.
Any ideas where I am going wrong?
Many Thanks
I have the follow peice of code which reads customer data from a text file, it then extracts the data in the Customer Name and email address fields. If the email address contains the @ symbol it writes the Customer Name and the email Address in to another text file. or at least its supposed to!!!
VB.NET:
' ------------------------------------------------------------------------------------------------------
' VARIABLES FOR TXT FILE READING AND WRITING
Dim File_NameIN As String = "C:\DRITXT\CUSTKEYA.txt"
Dim File_NameOUT As String = "C:\DRITXT\MAILOUT\EMAIL.txt"
Dim objWriter As New System.IO.StreamWriter(File_NameOUT)
' ------------------------------------------------------------------------------------------------------
' VARIABLES FOR PROCESSING DATA
Dim EmailAdd As String
Dim Customer As String
' ------------------------------------------------------------------------------------------------------
' RETREIVES EMAIL ADDRESS FROM CUSTKEYA AND WRITES IT TO EMAIL.TXT
For Each line As String In File.ReadAllLines(File_NameIN)
If line.Length = 581 Then
Customer = line.Substring(0, 30)
EmailAdd = line.Substring(274, 59).Trim.ToLower
End If
If EmailAdd.Contains("@") Then
objWriter.Write(EmailAdd & "," & Customer & ",")
End If
Next
objWriter.Dispose()
MsgBox("FILE CREATION COMPLETE", MsgBoxStyle.OkOnly)
If MsgBoxResult.Ok Then
Me.Show()
End If
Problem I am having is that it only writes the email address to the file, not the customer name.
Any ideas where I am going wrong?
Many Thanks