Private Sub Command1_Click()
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim sql As String
Dim strTest() As String
Dim strString() As String
Dim str As String, strTxt As String
Dim i
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " _
& "Data Source=" & App.Path & "\db1.mdb;Persist " _
& "Security Info=False;Jet OLEDB:Database Password="
Open App.Path & "\test.txt" For Input As #1
While Not EOF(1)
Line Input #1, str
If str = "" Then Exit Sub
strTxt = ""
strTest = Split(str)
For i = 0 To UBound(strTest)
If strTest(i) <> "" Then
strTxt = strTxt & strTest(i) & "/"
End If
Next i
Debug.Print strTxt
strString = Split(strTxt, "/")
If InStrRev(strString(2), "福建", , 1) Then
sql = "insert into tb (ip1,ip2,address,opt) " & _
"values ('" & strString(0) & "','" & strString(1) & "'," & _
"'" & strString(2) & "','" & strString(3) & "')"
cn.Execute sql
End If
Wend
Close #1
Set cn = Nothing
End Sub
While Not EOF(1)
Line Input #1, str
strtxt = ""
strtest = Split(str)
For i = 0 To UBound(strtest)
If strtest(i) <> "" Then
strtxt = strtxt & strtest(i) & "/"
End If
Next i
Debug.Print strtxt
strstring = Split(strtxt, "/")
' For i = 0 To UBound(strstring)
If InStrRev(strstring(2), "福建", , 1) Then
sql = "insert into tb (ip1,ip2,address,opt) " & _
"values ('" & strstring(0) & "','" & strstring(1) & "'," & _
"'" & strstring(2) & "','" & strstring(3) & "')"
Debug.Print sql
'Cn.Execute sql
End If
' Next i
For i = 0 To UBound(strString)
If InStrRev(strString(2), "福建", , 1) Then
sql = "insert into tb (ip1,ip2,address,opt) " & _
"values ('" & strString(0) & "','" & strString(1) & "'," & _
"'" & strString(2) & "','" & strString(3) & "')"
cn.Execute sql
End If
Next i