Private Sub GetRegDataInStruct() Dim FileNum As Integer, i As Integer, bStart As Boolean Dim TempString As String
With RegData(0)
For i = 0 To .RegFileCount - 1
If i = 0 Then .RegTitleCount = 0
FileNum = FreeFile: bStart = False Open .RegFile(i).RegFileName For Input As #FileNum Do While Not EOF(FileNum)
Line Input #FileNum, TempString
If ((bStart = True) And (TempString <> "")) Then ReDim Preserve .RegFile(i).RegFileData(.RegFile(i).RegFileDataCount) .RegFile(i).RegFileData(.RegFile(i).RegFileDataCount) = TempString .RegFile(i).RegFileDataCount = .RegFile(i).RegFileDataCount + 1 End If
If ((i = 0) And (bStart = False)) Then ReDim Preserve .RegTitle(.RegTitleCount) .RegTitle(.RegTitleCount) = TempString .RegTitleCount = .RegTitleCount + 1 End If
If InStr(UCase$(TempString), UCase$(KeyWord)) <> 0 Then bStart = True End If
DoEvents Loop Close #FileNum Next i
For i = 0 To .RegFileCount - 1 If GetNum(.RegFile(i).RegFileData(.RegFile(i).RegFileDataCount - 1)) > .MaxContactNum Then .MaxContactNum = GetNum(.RegFile(i).RegFileData(.RegFile(i).RegFileDataCount - 1)) '最大Contact Number End If Next i
Private Sub OutputBuffData() Dim FileNum As Integer, i As Long, j As Long, TotalCountNum As String Dim FileN As String, MyTime As String, Temp() As String
FileNum = FreeFile Open FileN For Output As #FileNum
For i = 0 To .RegTitleCount - 1 Print #FileNum, .RegTitle(i) Next i
TotalCountNum = 0 For i = 0 To RegData(0).MaxContactNum - 1 For j = 0 To 7 'All Site --> 0 ~ 7 If Trim(RegData(0).AllRegData(i, j)) <> "" Then TotalCountNum = TotalCountNum + 1 Print #FileNum, CStr(TotalCountNum) & " " & RegData(0).AllRegData(i, j) End If Next j Next i Close #FileNum
'debug log FileN = "C:\MiniRegMergeTool_" & Format(Now, "yyyymm") & ".log" FileNum = FreeFile Open FileN For Append As #FileNum Print #FileNum, Format(Now, "yyyy-mm-dd hh:mm:ss") & " -> " & TotalCountNum & vbCrLf Close #FileNum
Private Sub GetRegDataInStruct() Dim i As Integer, bStart As Boolean
With RegData(0)
For i = 0 To .RegFileCount - 1
If i = 0 Then .RegTitleCount = 0 Dim sr As StreamReader = New StreamReader(.RegFile(i).RegFileName) Dim line As String
Do line = sr.ReadLine() 'Console.WriteLine(line) If ((bStart = True) And (line <> "")) Then ReDim Preserve .RegFile(i).RegFileData(.RegFile(i).RegFileDataCount) .RegFile(i).RegFileData(.RegFile(i).RegFileDataCount) = line .RegFile(i).RegFileDataCount = .RegFile(i).RegFileDataCount + 1 End If
If ((i = 0) And (bStart = False)) Then ReDim Preserve .RegTitle(.RegTitleCount) .RegTitle(.RegTitleCount) = line .RegTitleCount = .RegTitleCount + 1 End If
If InStr(UCase$(line), UCase$(KeyWord)) <> 0 Then bStart = True End If
Loop Until line Is Nothing sr.Close()
Next i
For i = 0 To .RegFileCount - 1 If GetNum(.RegFile(i).RegFileData(.RegFile(i).RegFileDataCount - 1)) > .MaxContactNum Then .MaxContactNum = GetNum(.RegFile(i).RegFileData(.RegFile(i).RegFileDataCount - 1)) '最大Contact Number End If Next i
End With
End Sub
程序代码:
Private Sub OutputBuffData() Dim FileNum As Integer, i As Long, j As Long, TotalCountNum As String Dim FileN As String, MyTime As String, Temp() As String
Dim sw As StreamWriter = New StreamWriter(FileN) For i = 0 To .RegTitleCount - 1 sw.WriteLine(.RegTitle(i)) Next i
TotalCountNum = 0 For i = 0 To RegData(0).MaxContactNum - 1 For j = 0 To 7 'All Site --> 0 ~ 7 If Trim(RegData(0).AllRegData(i, j)) <> "" Then TotalCountNum = TotalCountNum + 1 sw.WriteLine(CStr(TotalCountNum) & " " & RegData(0).AllRegData(i, j)) End If Next j Next i sw.Close()