J
JenHu
Hi,
I want to open a file and read every line and characters. The
characters are fix length text file, no specific delimited method
between each fields. If the first character is "H" then it's a
header line; "D" or "R" means it's a content; "T" means it's a
footer line.
How to find the first character of each line?
and is it the right way to find the characters between position 73 and
85, and put into a variable by:
sBatchNum = RTrim(Mid$(sRetLine, 73, 85))
?
Thx
sample file:
------------------------------------------
H2004/07/2709:52:484.0TEST123MARKETING800302096510
D009084826009084826397000763333WITOWSKIDICK
41000620000520000010
F000W20040727FR3970007122228000000124444NWITOWSKIDICK 20040727250USD
D.........
F.........
T11 0 0 11 0 4250 0 0
my code:
-------------------------------------------------
Public Function ProcessRET(ByRef strFilepath As String)
Dim EpayConnection As New SqlConnection
Dim cmdBatchName As New SqlCommand
Dim dtrBatchName As SqlDataReader
EpayConnection.ConnectionString = strEpayDBConn
With cmdBatchName
.Connection = EpayConnection
.CommandText = "SELECT File_Name FROM EPay_Batch_Table
Where File_Status=2"
End With
EpayConnection.Open()
dtrBatchName = cmdBatchName.ExecuteReader()
dtrBatchName.Read()
Dim strRetFileName As String
strRetFileName = dtrBatchName("File_Name")
Dim ReturnFileName As String = strRetFileName.Replace(".in",
".RET")
Dim flRetBatch As File
Dim stRetBatch As FileStream
Dim smRetBatch As StreamReader
Dim sr As New StreamReader(strFilepath & ReturnFileName)
Dim sRetLine As String
Dim sBatchNum As String
sRetLine = sr.ReadLine
While Not sRetLine Is Nothing
If sRecordType = "H" Then
sBatchNum = RTrim(Mid$(sRetLine, 73, 85))
End If
End While
End Function
*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
I want to open a file and read every line and characters. The
characters are fix length text file, no specific delimited method
between each fields. If the first character is "H" then it's a
header line; "D" or "R" means it's a content; "T" means it's a
footer line.
How to find the first character of each line?
and is it the right way to find the characters between position 73 and
85, and put into a variable by:
sBatchNum = RTrim(Mid$(sRetLine, 73, 85))
?
Thx
sample file:
------------------------------------------
H2004/07/2709:52:484.0TEST123MARKETING800302096510
D009084826009084826397000763333WITOWSKIDICK
41000620000520000010
F000W20040727FR3970007122228000000124444NWITOWSKIDICK 20040727250USD
D.........
F.........
T11 0 0 11 0 4250 0 0
my code:
-------------------------------------------------
Public Function ProcessRET(ByRef strFilepath As String)
Dim EpayConnection As New SqlConnection
Dim cmdBatchName As New SqlCommand
Dim dtrBatchName As SqlDataReader
EpayConnection.ConnectionString = strEpayDBConn
With cmdBatchName
.Connection = EpayConnection
.CommandText = "SELECT File_Name FROM EPay_Batch_Table
Where File_Status=2"
End With
EpayConnection.Open()
dtrBatchName = cmdBatchName.ExecuteReader()
dtrBatchName.Read()
Dim strRetFileName As String
strRetFileName = dtrBatchName("File_Name")
Dim ReturnFileName As String = strRetFileName.Replace(".in",
".RET")
Dim flRetBatch As File
Dim stRetBatch As FileStream
Dim smRetBatch As StreamReader
Dim sr As New StreamReader(strFilepath & ReturnFileName)
Dim sRetLine As String
Dim sBatchNum As String
sRetLine = sr.ReadLine
While Not sRetLine Is Nothing
If sRecordType = "H" Then
sBatchNum = RTrim(Mid$(sRetLine, 73, 85))
End If
End While
End Function
*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*