[求助]哪里出了问题,总报错
Private Sub Command1_Click()CommonDialog1.DialogTitle = "打开文件"
CommonDialog1.Filter = "text files(*.txt)|*.txt|all files(*.*)|(*.*)"
CommonDialog1.InitDir = 0
CommonDialog1.ShowOpen
Text1.Text = CommonDialog1.FileName
'Me.Text1.Enabled = False
End Sub
Private Sub Command2_Click()
If Text1.Text = "" Then
MsgBox "请选择一个文件!"
End If
Dim temp As String
Open CommonDialog1.FileName For Input As #1
Do While Not EOF(1)
Line Input #1, temp '读出每条记录,然后判断含有的字段
InputDataBase (temp) 'function insert database
Loop
Close #1
Do While Not EOF(1) '遍历数据库的每行数据
a = GetDataFromDatabase(strCardType1, strCardType2) '形参是卡种1和卡种2
Loop
End Sub
Private Function GetDataFromDatabase(ByVal strCardType1 As String, strCardType2 As String)
Dim conn As New ADODB.Connection
Dim strSql As String
Dim strCombine As String
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;DataSource=" & App.Path & "db1.mdb;Persist Security Info=False"
conn.Open
strSql = "select * from a1 where 卡种1='" & strCardType1 & "' and 卡种2='" & strCardType2 & "'"
Set obRecordSet = conn.Execute strSql
strCombine = objRecordSet.Fields("序号") & objRecordSet.Fields("信用卡卡号") & objRecordSet.Fields("持卡人性别和姓名拼音")
&_ objRecordSet.Fields("有效期") &_ objRecordSet.Fields("写磁信息") & _objRecordSet.Fields("卡种类1")
& objRecordSet.Fields("卡种类2") & vbCrLf
Open strCardType1 & strCardType2.txt For Output As #2
Print #2, strCombine
Close #2
End Function
Public Function ConnectString(ByVal apppath As String) As String
ConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;" & "data source=" & apppath & "db1.mdb"
End Function
Dim strSql As String
Dim strId As String
Dim strCardId As String
Dim strUserName As String
Dim strExpireDate As String
Dim strInfo As String
Dim strCardType1 As String
Dim strCardType2 As String
strId = Mid(Trim(InInfo), 0, 6)
strCardId = Mid(Trim(InInfo), 7, 16)
strUserName = Mid(Trim(InInfo), 24, 34)
strExpireDate = Mid(Trim(InInfo), 59, 4)
strInfo = Mid(Trim(InInfo), 64, 36)
strCardType1 = Mid(Trim(InInfo), 102, 2)
strCardType2 = Mid(Trim(InInfo), 104, 2)
strSql = "INSERT INTO a1 (序号,信用卡卡号,持卡人性别和姓名拼音,有效期,写磁信息,卡种类1,卡种类2) values (strId,strCardId,strUserName,strExpireDate,strInfo,strCardType1,strCardType2)"
conn.Execute strSql
End Function
Private Sub Command3_Click()
Unload Me
End Sub