vb中sub参数传递问题
代码如下,如果调用下面的插入函数向mdb数据库中插数据字符串前置的零和和置的零就都不显示,而将如下代码在主程序中直接调用就正常,晕死PublicSubInsertMdb(...
代码如下,如果调用下面的插入函数向mdb数据库中插数据字符串前置的零和和置的零就都不显示,而将如下代码在主程序中直接调用就正常,晕死
Public Sub InsertMdb(ByVal Table As String, ByRef QiHao As String, ByRef KJHaoMa As String, Optional ByVal ChongFu As Boolean)
Dim tempsql, a, b As String
Dim temprecord As ADODB.Recordset
Set temprecord = New ADODB.Recordset
a = CStr(QiHao)
b = CStr(KJHaoMa)
tempsql = "insert into " & Table & " (期号,开奖号码) values (" & a & "," & b & ")"
'tempsql = "insert into " & Table & " (期号,开奖号码) values (QiHao,KJHaoMa)"
temprecord.open tempsql, dbConn, adOpenStatic, adLockOptimistic, adCmdText
End Sub
主程序如下
Dim Temp() As String
For i = 0 To 10 'UBound(urlJieQu) - LBound(urlJieQu)
Temp = Split(getKaiJiang(getHtmlTxt(Http & urlJieQu(i))))
Call InsertMdb("历史开奖", Temp(0), Temp(1))‘此处如果不调用insertmdb,而直接将insertmdb中的代码写过来就能正常显示前置或后置的零,不知道我表达的清楚没有
不是MDB的问题,MDB里已经改成字符型了 展开
Public Sub InsertMdb(ByVal Table As String, ByRef QiHao As String, ByRef KJHaoMa As String, Optional ByVal ChongFu As Boolean)
Dim tempsql, a, b As String
Dim temprecord As ADODB.Recordset
Set temprecord = New ADODB.Recordset
a = CStr(QiHao)
b = CStr(KJHaoMa)
tempsql = "insert into " & Table & " (期号,开奖号码) values (" & a & "," & b & ")"
'tempsql = "insert into " & Table & " (期号,开奖号码) values (QiHao,KJHaoMa)"
temprecord.open tempsql, dbConn, adOpenStatic, adLockOptimistic, adCmdText
End Sub
主程序如下
Dim Temp() As String
For i = 0 To 10 'UBound(urlJieQu) - LBound(urlJieQu)
Temp = Split(getKaiJiang(getHtmlTxt(Http & urlJieQu(i))))
Call InsertMdb("历史开奖", Temp(0), Temp(1))‘此处如果不调用insertmdb,而直接将insertmdb中的代码写过来就能正常显示前置或后置的零,不知道我表达的清楚没有
不是MDB的问题,MDB里已经改成字符型了 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询