hi, i am very new to vb. i get basic syntax and the like...
what i am trying to do:
we upload text files to a state agency. any records in the file that contain errors bounce back to us in a text file with the error code at the end of the file. the error file is not delimited in any way, it is just fixed width. i have managed to hack together something using many of the various msdn help and samples that will allow me to hardcode the filename of the source and destination. this runs pretty much as a quicky console app with almost no user input. i am trying to make a form that will allow the user to select what type of error file it is (eventually we will deal with 6-8 different types), probably by using an option group with radio buttons, and the openFileDialog to browse to the location of the error file.
now the problem: in the console you can use StreamReader and StreamWriter to easily do the basics of pulling the info from the textfile, but with the openFileDialog, VB Express says I need a Stream, not a StreamReader to work with it. How do I do this??
This is what i have for the "console" version.
If there is a better way to manage the GUI pieces, i would love any guidance.
Thanks for any help....
what i am trying to do:
we upload text files to a state agency. any records in the file that contain errors bounce back to us in a text file with the error code at the end of the file. the error file is not delimited in any way, it is just fixed width. i have managed to hack together something using many of the various msdn help and samples that will allow me to hardcode the filename of the source and destination. this runs pretty much as a quicky console app with almost no user input. i am trying to make a form that will allow the user to select what type of error file it is (eventually we will deal with 6-8 different types), probably by using an option group with radio buttons, and the openFileDialog to browse to the location of the error file.
now the problem: in the console you can use StreamReader and StreamWriter to easily do the basics of pulling the info from the textfile, but with the openFileDialog, VB Express says I need a Stream, not a StreamReader to work with it. How do I do this??
This is what i have for the "console" version.
Code:
Imports System
Imports System.IO
Imports Microsoft.VisualBasic.Strings
Class Test
Public Shared Sub Main()
Try
' Create an instance of StreamReader to read from a file.
Dim sr As StreamReader = New StreamReader("C:\qryDemographic_1-27-06 412.txt")
Dim sw As StreamWriter = New StreamWriter("C:\ErrorFile.txt")
Dim line As String
Dim column1 As String
Dim column2 As String
' Read and display the lines from the file until the end
' of the file is reached.
Do
line = sr.ReadLine()
column1 = Mid(line, 11,9)
column2= mid(Line,165)
sw.WriteLine(column1 & " " & column2)
Loop Until line Is Nothing
sr.Close()
sw.Close()
Catch d As Exception
' Let the user know what went wrong.
Console.WriteLine("The file could not be read:")
Console.WriteLine(d.Message)
End Try
End Sub
End Class
Thanks for any help....