|
asp与vba写法有些类似,只是ado和mdb路径要改一下.下面作为参考(文本框名改了text0,红色的估计原文写错了):
Private Sub Command2_Click()
strchar = Trim(Me.Text0)
If strchar <> "" Then
lstr = Len(strchar)
lstr = lstr - 11 - 5 - 2 - 6
str1 = Mid(strchar, 12, 5) '12到16
str2 = Mid(strchar, 19, 6) '19到24
str3 = Mid(strchar, 27, lstr) '27以后
str4 = "20" & Left(str2, 2) & "/" & Mid(str2, 3, 2) & "/" & Right(str2, 2)
Dim conn As New ADODB.Connection
conn.Provider = "Microsoft.Jet.OLEDB.4.0;"
conn.ConnectionString = 这里写mdb文件的绝对路径 & "\DB_txm.mdb"
conn.Open
SQL = "Insert into tab_str (char1,char2,char3,char4) values (" & """" & str1 & """" & "," & """" & str2 & """" & "," & """" & str3 & """" & "," & """" & str4 & """" & " )"
conn.Execute SQL
conn.Close
Set conn = Nothing
End If
End Sub
|
|