vb中怎样将数字赋值给组合框中的各项文字

2024-12-16 03:07:54
推荐回答(4个)
回答1:

可以用数组来实现,也可以添加一个辅助的框,如Combo2:
Private Sub Combo1_Click()
If Me.Visible Then MsgBox Combo2.List(Combo1.ListIndex)
End Sub

Private Sub Form_Load()
For Each s In Split("U1,U2,U3,U4,U5", ",")
Combo1.AddItem s
Next
For Each s In Split("30,31,32,33,34", ",")
Combo2.AddItem s
Next
Combo2.Visible = False
Combo1.ListIndex = 0
End Sub

回答2:

在Windows平台Visual Basic6开发环境中,只需在工程中包含Kodak图像控件即可用于开发。方式是:点击菜单“Project”-“compfonents”,在组件对话框中,勾选Kodak图像四控件。随后,四控件出现在控件工具栏中,拖动或双击这些控件到VB表单上即可。

回答3:

Private Sub Form_Load()
Combo1.AddItem u1
Combo1.AddItem u2
Combo1.AddItem u3
Combo1.AddItem u4
Combo1.AddItem u5
End Sub
Private Sub Combo1_Click()
Select Case Combo1.Text
Case "u1"
u1 = 30
Case "u2"
u2 = 31
Case "u3"
u3 = 32
Case "u4"
u4 = 33
Case "u5"
u5 = 34
End Select
End Sub

回答4:

组合框指的什么控件?