Dear everyone, come on... Who can help me with the name problem and the summary row problem in the last line... Little sister is eagerly looking forward...
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!
Originally posted by dhlmdsnw at 2008-1-30 21:51:
Oh my god, I'm so happy I've lost all sense of proportion. Oh, I forgot to ask: Mr. terse, does your code support foreign names?
Const ForReading = 1 'Set the text opening method to reading
Const ForWriting = 2 'Set the text opening method to writing
Const ForAppending = 8 'Set the text opening method to appending
Const InFile = "a.txt" 'Set the text to open
Dim i
Dim StrLine,OutStr
i = 1
'On Error Resume Next
Set objFSO = CreateObject("Scripting.FileSystemObject") 'Reference the FSO object, which is used for reading and writing files
Set objFile = objFSO.OpenTextFile(InFile, ForReading) 'Open InFile in reading mode
Do Until objFile.AtEndOfStream
StrLine = objFile.ReadLine 'Read a line
If Len(StrLine) Then 'If it is not an empty line
StrLine = FixStr(StrLine)
NeedData = Split(StrLine," ")
If Right(NeedData(1),1) = "*" Then NeedData(1) = Left(NeedData(1),Len(NeedData(1)) - 1)
OutLine = "2140800050202" & NeedData(1) & "3" & AddZero(i,6) & "00" & NeedData(2)
OutLine = OutLine & "000000000000000011 " & AddZero(i - 1,9) & NeedData(4)
OutStr = OutStr & OutLine & vbCrLf
i = i + 1
End If
Loop
OutStr = OutStr & "14080005020214080100112003624143" & AddZero(i,6)
OutStr = OutStr & "00000000001775000000000000000000072 " 'Did you miss writing 2 above? The meaning of 2 is unclear.
objFile.Close 'Close the file object
OutFile = "140820" & FormatDate(Date) & "001.txt"
Set objFile = objFSO.OpenTextFile(OutFile, ForWriting,True) 'Open OutFile in writing mode
objFile.Write OutStr
objFile.Close 'Close the file object
Set objFile = Nothing
Set objFSO = Nothing
Function FixStr(StrExp)
Do While InStr(StrExp," ")
StrExp = Replace(StrExp," "," ")
Loop
FixStr = StrExp
End Function
Function FormatDate(tDate)
FormatDate = Right(Year(tDate),2) & AddZero(Month(tDate),2) & AddZero(Day(tDate),2)
End Function
Function AddZero(sNum,iLen)
Addzero = Right("000000000" & sNum,iLen)
End Function