注册 登录
编程论坛 VB6论坛

提示参数类型不正确,或不在可以接受的范围之内,...

gulongcun 发布于 2012-02-24 13:30, 565 次点击
代码如下,提示参数类型不正确,或不在可以接受的范围之内,...请高手帮忙!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Private Sub Command1_Click()
  For Index = 0 To 4   '清空所有的text
  Text1(Index).Text = ""
  Next
  Text1(0).SetFocus
End Sub



Private Sub Command2_Click()
Dim SQL_jl As String
Dim rs As New ADODB.Recordset
If Text1(0).Text = "" Then   '检查编号是否为空
MsgBox "请输入借款人编号!"
Text1(0).SetFocus
Exit Sub
End If
If Text1(1).Text = "" Then   '检查姓名是否为空
MsgBox "请输入借款人姓名!"
Text1(1).SetFocus
Exit Sub
End If
If Text1(2).Text = "" Then   '检查时间是否为空
MsgBox "请输入借款时间!"
Text1(2).SetFocus
Exit Sub
End If
If Text1(3).Text = "" Then    '检查金额是否为空
MsgBox "请输入借款金额!"
Text1(3).SetFocus
Exit Sub
End If
If Text1(4).Text = "" Then    '检查说明是否为空
MsgBox "请输入借款说明!"
Text1(4).SetFocus
Exit Sub
End If
SQL_jl = "select * from 记录 where id='" & Text1(0).Text & "'"
rs.Open SQL_jl, Conn, adOpenKeyset, adOpenStatic
If rs.EOF Then
rs.AddNew                                   '写入数据
rs.Fields(0) = Text1(0).Text
rs.Fields(1) = Text1(1).Text
rs.Fields(2) = Text1(2).Text
rs.Fields(3) = Text1(3).Text
rs.Fields(4) = Text1(4).Text
rs.Update
MsgBox "借款记录添加成功!"
Text1(0).Text = ""
Text1(1).Text = ""
Text1(2).Text = ""
Text1(3).Text = ""
Text1(4).Text = ""
Text1(0).SetFocus
Else
MsgBox "此ID已存在,请输入新ID!"
Text1(0).Text = ""
Text1(0).SetFocus
End If
rs.Close
Set rs = Nothing
End Sub

Private Sub Command3_Click()
Unload Me
Form2.Show
End Sub

Private Sub Form_Load()
Dim Connectionstring As String
Me.Top = (Screen.Height - Me.Height) / 2    'ME代表本窗体
Me.Left = (Screen.Width - Me.Width) / 2
Set Conn = New ADODB.Connection
Conn.Connectionstring = "provider=Microsoft.Jet.oledb.4.0;" & _
"Data Source=" & App.Path & "\wlk.mdb"
Conn.Open
End Sub
4 回复
#2
Artless2012-02-25 00:21
id类型?
#3
mayuebo2012-02-27 21:33
Index,换一个吧.

运行时看看光标停在哪一行上.就是那行的问题了,你把所有的代码都发出来,又不说是哪行的问题,比较麻烦呀
#4
Artless2012-02-28 01:17
以下是引用mayuebo在2012-2-27 21:33:33的发言:

 Index,换一个吧.

运行时看看光标停在哪一行上.就是那行的问题了,你把所有的代码都发出来,又不说是哪行的问题,比较麻烦呀

以下是引用gulongcun在2012-2-24 13:30:23的发言:

代码如下,提示参数类型不正确,或不在可以接受的范围之内,
#5
mayuebo2012-02-28 07:49
直接按F8,看看哪行弹出提示
1