Private Sub LoadCJ()
Dim TextLine As String
Dim X
Dim i, c As Integer
Dim s1 As String
Dim s2 As String
Dim p1, p2, p3, err As Long
LE.Visible = False
LE.Caption = "出错行:"
strSql = "delete from USERINFO"
If sql_put(strSql) = True Then
strSql = "delete from PREDIALTASK"
If sql_put(strSql) = True Then
p3 = 0
End If
End If
Open txtF For Input As #1
Do While Not EOF(1) ' 循环至文件尾
Line Input #1, TextLine
If InStr(1, TextLine, vbTab, vbBinaryCompare) > 0 Then
X = Split(TextLine, vbTab)
Else
X = Split(TextLine, ",")
End If
If (p3 > 0) Then
s1 = "insert into USERINFO(MONEY1,MONEY2"
s2 = " values('" & X(KMCol(0) - 1) & "','" & X(KMCol(1) - 1)
For i = 2 To MaxKM + 1
s1 = s1 & ",TEL" & i - 1
s2 = s2 & "','" & FmtCJ(Trim(X(KMCol(i) - 1)))
Next i
strSql = s1 & ")" & s2 & "')"
p1 = p1 + 1
If sql_put(strSql) = True Then
p2 = p2 + 1
Else
err = err + 1
LE.Caption = LE.Caption & p1 & ":"
LE.Visible = True
If err > 5 Then
MsgBox "导入未完成,失败次数太多!", vbCritical, strTitle
GoTo Ex
End If
End If
' st = FmtCJ(Trim(X(KMCol(2) - 1)))
st = 812
frmAdd.InsertDial (st)
L.Caption = "导入进度: " & p2 & " / " & p1
End If
p3 = p3 + 1
DoEvents
Loop
MsgBox "导入已完成!", vbInformation, strTitle
Ex:
Close #1
End Sub
frmAdd的InsertDial 方法:
Public Sub InsertDial(st As String)
Dim stp As Integer
iRerr = 0
sr = 0
stp = 0
If IsNumeric(st) Then
If stp = 0 Then
stp = 1
srtmp = 0
End If
If stp = 1 Then
bb = DateAdd("s", (srtmp / Dialogs) * DialLong, DTP(0))
If bb <= DTP(1) Then
DTPicker1 = Format(DT(0), "YYYY-MM-DD") & " " & Format(bb, "HH:MM:SS")
DTPicker2 = Format(DT(0), "YYYY-MM-DD") & " " & Format(DTP(1), "HH:MM:SS")
Call AddRecord(st)
If Check1(0) Then
stp = 2
Else
GoTo Nxt:
End If
Else
stp = 2
End If
End If
If stp = 2 Then
If Check1(0) Then
If stp = 2 Then
stp = 3
srtmp = 0
End If
End If
End If
If stp = 3 Then
bb = DateAdd("s", (srtmp / Dialogs) * DialLong, DTP(2))
If bb <= DTP(3) Then
DTPicker1 = Format(DT(0), "YYYY-MM-DD") & " " & Format(bb, "HH:MM:SS")
DTPicker2 = Format(DT(0), "YYYY-MM-DD") & " " & Format(DTP(3), "HH:MM:SS")
' Call AddRecord(st)
If Check1(1) Then
stp = 4
Else
GoTo Nxt:
End If
Else
stp = 4
End If
End If
If stp = 4 Then
If Check1(1) Then
If stp = 4 Then
stp = 5
srtmp = 0
End If
End If
End If
If stp = 5 Then
bb = DateAdd("s", (srtmp / Dialogs) * DialLong, DTP(4))
If bb <= DTP(5) Then
DTPicker1 = Format(DT(0), "YYYY-MM-DD") & " " & Format(bb, "HH:MM:SS")
DTPicker2 = Format(DT(0), "YYYY-MM-DD") & " " & Format(DTP(5), "HH:MM:SS")
' Call AddRecord(st)
GoTo Nxt:
End If
End If
Nxt:
DoEvents
If iRerr = 3 Then
MsgBox "无法继续执行,操作被中止。请尝试关闭程序重新尝试。", vbInformation, strTitle
End If
End If
End Sub