有关VB的问题 我想在车型的下拉菜单里选中一个ACCESS内的值 选中这个值后 下面三个长宽高可随之显示
这三个text框不用可输入可从数据库中被读出来就行主要是对应关系麻烦指教下在线等答得好的给追加分哦~麻烦各位大虾了~麻烦大虾们说的详细点最好能把程序帮我编一下我很菜~~...
这三个text框不用可输入 可从数据库中被读出来就行 主要是对应关系 麻烦指教下 在线等 答得好的给追加分哦~ 麻烦各位大虾了~
麻烦大虾们说的详细点 最好能把程序帮我编一下 我很菜~~ 展开
麻烦大虾们说的详细点 最好能把程序帮我编一下 我很菜~~ 展开
3个回答
展开全部
'access 数据表表名:chexing
'结构id、chexing、chang、kuan、gao
Dim id() As Long
Dim chang() As Long
Dim kuan() As Long
Dim gao() As Long
Private Sub Combo1_Click()
Text1.Text = chang(Combo1.ListIndex)
Text2.Text = kuan(Combo1.ListIndex)
Text3.Text = gao(Combo1.ListIndex)
End Sub
Private Sub Form_Load()
ReDim id(0)
ReDim chang(0)
ReDim kuan(0)
ReDim gao(0)
Combo1.Clear
db = "d:\chexing.mdb"
connstr = "DBQ=" + db + ";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)}"
Set conn = CreateObject("ADODB.Connection")
conn.Open connstr
websql = "select * from chexing order by id"
Set rs = CreateObject("adodb.recordset")
rs.Open websql, conn, 1, 1
If rs.EOF And rs.BOF Then
Else
Do While Not rs.EOF
Combo1.AddItem rs("chexing")
id(UBound(id)) = rs("id")
ReDim Preserve id(UBound(id) + 1)
chang(UBound(chang)) = rs("chang")
ReDim Preserve chang(UBound(chang) + 1)
kuan(UBound(kuan)) = rs("kuan")
ReDim Preserve kuan(UBound(kuan) + 1)
gao(UBound(gao)) = rs("gao")
ReDim Preserve gao(UBound(gao) + 1)
rs.MoveNext
Loop
End If
rs.Close
Set rs = Nothing
Set conn = Nothing
Combo1.ListIndex = 0
End Sub
'结构id、chexing、chang、kuan、gao
Dim id() As Long
Dim chang() As Long
Dim kuan() As Long
Dim gao() As Long
Private Sub Combo1_Click()
Text1.Text = chang(Combo1.ListIndex)
Text2.Text = kuan(Combo1.ListIndex)
Text3.Text = gao(Combo1.ListIndex)
End Sub
Private Sub Form_Load()
ReDim id(0)
ReDim chang(0)
ReDim kuan(0)
ReDim gao(0)
Combo1.Clear
db = "d:\chexing.mdb"
connstr = "DBQ=" + db + ";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)}"
Set conn = CreateObject("ADODB.Connection")
conn.Open connstr
websql = "select * from chexing order by id"
Set rs = CreateObject("adodb.recordset")
rs.Open websql, conn, 1, 1
If rs.EOF And rs.BOF Then
Else
Do While Not rs.EOF
Combo1.AddItem rs("chexing")
id(UBound(id)) = rs("id")
ReDim Preserve id(UBound(id) + 1)
chang(UBound(chang)) = rs("chang")
ReDim Preserve chang(UBound(chang) + 1)
kuan(UBound(kuan)) = rs("kuan")
ReDim Preserve kuan(UBound(kuan) + 1)
gao(UBound(gao)) = rs("gao")
ReDim Preserve gao(UBound(gao) + 1)
rs.MoveNext
Loop
End If
rs.Close
Set rs = Nothing
Set conn = Nothing
Combo1.ListIndex = 0
End Sub
展开全部
在车型上加一个事件,值有变更的时候的用ADO读取一下数据就行了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
select * from 表 where 车型='车型列表下拉值'
取出数据后进行是否为空的判断
if rs.rowcount<>0 then
长=rs(长)
end if
取出数据后进行是否为空的判断
if rs.rowcount<>0 then
长=rs(长)
end if
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询