该如何加速?至少也要1秒100MB左右才合理吧~
27.4MB的档案VB6要转5分多~再这样我要放弃VB6的了~改用C写了~该如何加速?24.7MB只是测试档~实际上要考虑转 ?GB 级的档案~所以速度上实在不行~
速度是用API測的
程序代码:
Option Explicit Dim FileName As String Private Sub Command1_Click() Dim S1 As Currency, S2 As Currency, f As Currency, t1 As Currency '計時用 On Error GoTo ErrorHandling FileName = "" Dialog1.ShowOpen FileName = Dialog1.FileName If FileName <> "" Then FileName = Trim(FileName) Text1.Text = FileName Text1.ToolTipText = FileName Call QueryPerformanceFrequency(f) '計時 Call QueryPerformanceCounter(S1) '計時 Call UNIX2Dos(FileName) ' Call TransFileFormat(FileName) Call QueryPerformanceCounter(S2) '計時 t1 = (S2 - S1) / f '計時 MsgBox t1 End If Exit Sub ErrorHandling: Call ErrorWriteBuff(FileName, iCount, "TransformFile", Err.Number, Err.Description, "系統訊息") Resume Next End Sub Private Sub Form_Initialize() ErrorCount = 0: ReDim ErrorData(ErrorCount) End Sub
程序代码:
Option Explicit Public ErrorCount As Long Public ErrorData() As String Public iCount As Long Public Declare Function QueryPerformanceCounter Lib "kernel32" (x As Currency) As Boolean Public Declare Function QueryPerformanceFrequency Lib "kernel32" (x As Currency) As Boolean Public Function UNIX2Dos(FileName As String) As String Dim FileNum1 As Integer, FileNum2 As Integer, i As Long Dim TempString As Byte, newFileName As String On Error GoTo ErrorHandling iCount = 0 newFileName = Mid(FileName, 1, InStrRev(FileName, ".") - 1) & "_new.log" FileNum1 = FreeFile: FileNum2 = FreeFile + 1 Open newFileName For Binary Access Write As #FileNum2 Open FileName For Binary Access Read As #FileNum1 Do While Not EOF(FileNum1) Get #FileNum1, , TempString If TempString = 10 Then Put #FileNum2, , CByte(Val(10)) Put #FileNum2, , CByte(Val(13)) Else Put #FileNum2, , CByte(Val(TempString)) End If iCount = iCount + 1 DoEvents Loop Close #FileNum1, #FileNum2 UNIX2Dos = newFileName Exit Function ErrorHandling: Call ErrorWriteBuff(FileName, iCount, "TransformFile", Err.Number, Err.Description, "系統訊息") Resume Next End Function
[ 本帖最后由 wube 于 2011-5-20 21:47 编辑 ]