View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
NickHK NickHK is offline
external usenet poster
 
Posts: 4,391
Default Could not set the Text property of a ComboBox on User Form.

Well this code errors as expected in my version of Excel 2002 :

Private Sub UserForm_Initialize()
With ComboBox1
.Style = fmStyleDropDownList
.AddItem "Item 1"
.AddItem "Item 2"
.AddItem "Item 3"
.AddItem "Item 4"

.Text = "Not in list"
End With
End Sub

but this not not :

Private Sub UserForm_Initialize()
With ComboBox1
.Style = fmStyleDropDownCombo
.AddItem "Item 1"
.AddItem "Item 2"
.AddItem "Item 3"
.AddItem "Item 4"

.Text = "Not in list"
End With
End Sub

Read the help on the .Style property.

NickHK

"??????? ?. ???????" wrote in message
...
Why? The ComboBox1.MatchEntry is fmMatchEntryNone, and
ComboBox1.MatchRequired is False. And it works fine in the Office 2002.

And
what You do suggest?

"NickHK" ?????:

Yes, that means you cannot set .Text to a value that is not in the list.

NickHK

"??????? ?. ???????" wrote in message
...
ComboBox1.Style equals to fmStyleDropDownList

"NickHK" ?????:

What is combo box's .Style set to ?
If it is 2-List, change to 0-Combo.

NickhK

"??????? ?. ???????" wrote in message
...
The statement
ComboBox1.Text = "1,2,3"
yields to a run-time error. The ComboBox1.MatchEntry is

fmMatchEntryNone,
and ComboBox1.MatchRequired is False . The "1,2,3" does not match

any
entry
in the ComboBox1 at the time, but I want to show it in the edit

field of
the
combo box.