Bigbadborris
Active member
- Joined
- Aug 21, 2013
- Messages
- 35
- Programming Experience
- Beginner
Hi all
I have this piece of code that organizes a text file created by File-pro into a more reasonable format. The code works perfect however I get the following message.
"Object Reference not set to an instance of an object"
Can someone please tell me where i have gone wrong.
Many Thanks
I have this piece of code that organizes a text file created by File-pro into a more reasonable format. The code works perfect however I get the following message.
"Object Reference not set to an instance of an object"
Can someone please tell me where i have gone wrong.
Many Thanks
VB.NET:
Imports System.IO
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim File_NameIN As String = "C:\Users\Paul Murphy\Documents\DataFiles\CUSTKEY.txt"
Dim File_NameOUT As String = "C:\Users\Paul Murphy\Documents\DataFiles\CUSTKEYA.txt"
Try
Using SR As New StreamReader(File_NameIN)
Using SW As New StreamWriter(File_NameOUT)
Do
Dim strLine As String = SR.ReadLine()
Dim strLine2 As String
For i As Integer = 1 To strLine.Length Step 581
strLine2 = strLine.Remove(0, 601)
SW.WriteLine(Mid(strLine2, i, 581))
Next i
Loop
End Using
End Using
Catch ex As Exception
MsgBox(ex.Message)
Exit Sub
End Try
MsgBox(File_NameOUT & " written")
End Sub
End Class