问一个关于VB的问题我选用combobox(组合框),下拉选定的item如何去display在另一个text中.
txtTemp.Text = ???
说的白点儿:就是从下拉菜单(friend, colleague, classmate)一组中选中一个或几个,然后显示"friend.."在一个文本框中.how to implement?
I know should use combox, but how to write code?[澳洲野狗 (3-8 23:57, Long long ago)]
[ 传统版 |
sForum ][登录后回复]1楼
能不能这样写?比如combobox name is"cmbox"
IF cmbox.ListIndex = 0 Then cmbox.Text = "Family"
Else
IF cmbox.ListIndex = 1 Then cmbox.Text = "Colleague"
'Else If .....
txtTemp.Text = cmbox.Text
[澳洲野狗 (3-9 0:22, Long long ago)]
[ 传统版 |
sForum ][登录后回复]2楼
试一下这样写Private Sub Combobox_Click()
txtTemp.Text = Combobox.Text
End Sub
[瞌睡虫 (3-9 14:15, Long long ago)]
[ 传统版 |
sForum ][登录后回复]3楼
(引用 澳洲野狗:能不能这样写?比如combobox name is"cmbox" IF cmbox.ListIndex = 0 Then cmbox.Text = "Family" Else IF cmbox.ListIndex = 1 Then cm...)i tried ,cannot:([澳洲野狗 (3-9 14:21, Long long ago)] [ 传统版 | sForum ][登录后回复]4楼
try thisfirst place one textbox and combobox on the form. name them text1 and combo1 respectively.....
Private Sub Form_Load()
Combo1.Clear
Combo1.AddItem "AAA"
Combo1.AddItem "BBB"
Combo1.AddItem "CCC"
Combo1.AddItem "DDD"
End Sub
Private Sub Combo1_Click()
Text1.Text = Combo1.Text
End Sub
or u can try this
Private Sub text1_gotfocus()
If Combo1.Text = "" Then
MsgBox "Please select a value from the list first."
Combo1.SetFocus
Exit Sub
Else
Text1.Text = Combo1.Text
End If
End Sub
Private Sub Form_Load()
Combo1.Clear
Combo1.AddItem "AAA"
Combo1.AddItem "BBB"
Combo1.AddItem "CCC"
Combo1.AddItem "DDD"
End Sub
[flybird111 (3-9 19:53, Long long ago)]
[ 传统版 |
sForum ][登录后回复]5楼