Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default New to ComboBox

Hi:

I have a ComboBox called cboList. My code follows:

-------------------------------------------------------
1
-------------------------------------------------------
Private Sub cboList_DropButtonClick()
Dim arr(1 To 2) As String
Dim i As Integer

arr(1) = "Test1"
arr(2) = "Test2"

cboPortfolioList.Clear

For i = 1 To 2
cboPortfolioList.AddItem arr(i)
Next i

End Sub

The DropButtonClick funttion works just fine. But when I
tried to select a value, I could't see the selected value
in the ComboBox. I tried to use Application.ScreenUpdating
= True to see what's happening. It seemed that my selected
value appeared for 1/1000 sec and then dissapeared.

I also tried the following, which also failed:

-------------------------------------------------------
2
------------------------------------------------------
Private Sub cboList_Change()
Select Case cboList.Value
Case 0
cboList.Text = "Test1"
Case 1
cboList.Text = "Test2"
End Select
End Sub

Following code works:
---------------------------------------------------------
3
--------------------------------------------------------

Private Sub cboList_Change()
Select Case cboList.Value
Case 0
cboList.Text = "Test 1"
Case 1
cboList.Text = "Test 2"
End Select
End Sub

NOTICE the string values in the third code are with space,
i.e. "Test 1" and not "Test1". In another word, the text
property works if the assigned value is not equal to the
value property.


My question is how can I make my selection permanently
visible? Shouldn't the ComboBox control automatically
change its value to user's selection? and why does the
text property only work if its value is different from the
value property?


Regards,
Adrian T
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default New to ComboBox

I would drop all that code an initialize the combobox when the userform is
displayed

Private Sub Userform_Initialize()
Dim arr(1 To 2) As String
Dim i As Integer

arr(1) = "Test1"
arr(2) = "Test2"

cboPortfolioList.Clear

For i = 1 To 2
cboPortfolioList.AddItem arr(i)
Next i

End Sub

--
Regards,
Tom Ogilvy


"Adrian T" wrote in message
...
Hi:

I have a ComboBox called cboList. My code follows:

-------------------------------------------------------
1
-------------------------------------------------------
Private Sub cboList_DropButtonClick()
Dim arr(1 To 2) As String
Dim i As Integer

arr(1) = "Test1"
arr(2) = "Test2"

cboPortfolioList.Clear

For i = 1 To 2
cboPortfolioList.AddItem arr(i)
Next i

End Sub

The DropButtonClick funttion works just fine. But when I
tried to select a value, I could't see the selected value
in the ComboBox. I tried to use Application.ScreenUpdating
= True to see what's happening. It seemed that my selected
value appeared for 1/1000 sec and then dissapeared.

I also tried the following, which also failed:

-------------------------------------------------------
2
------------------------------------------------------
Private Sub cboList_Change()
Select Case cboList.Value
Case 0
cboList.Text = "Test1"
Case 1
cboList.Text = "Test2"
End Select
End Sub

Following code works:
---------------------------------------------------------
3
--------------------------------------------------------

Private Sub cboList_Change()
Select Case cboList.Value
Case 0
cboList.Text = "Test 1"
Case 1
cboList.Text = "Test 2"
End Select
End Sub

NOTICE the string values in the third code are with space,
i.e. "Test 1" and not "Test1". In another word, the text
property works if the assigned value is not equal to the
value property.


My question is how can I make my selection permanently
visible? Shouldn't the ComboBox control automatically
change its value to user's selection? and why does the
text property only work if its value is different from the
value property?


Regards,
Adrian T



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
For Each Combobox jlclyde Excel Discussion (Misc queries) 3 September 10th 09 05:06 PM
fill combobox depending on selection from another combobox Adam Francis Excel Discussion (Misc queries) 2 July 24th 08 07:39 PM
combobox value flow23 Excel Discussion (Misc queries) 0 April 26th 06 12:21 PM
Combobox nc Excel Discussion (Misc queries) 1 September 28th 05 02:11 PM
Combobox Tony G[_2_] Excel Programming 1 October 24th 03 01:53 PM


All times are GMT +1. The time now is 02:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"