I have a combo box with its Style property set to "0 - Dropdown combo".
Storing its value to the database poses a strange problem.
Let's say I have a combo box with its Style property set to "0 - Dropdown combo"
And I populate it like this:
Then let's say for a specific record, I read its value from the database and show it like this (for simplicity I am hard-coding the value instead of actually reading it from database):
Then I click on this button:
Here is the result:
cbo1.ListCount = 3
cbo1.ListIndex = -1
cbo1.Text = Two
cbo1.List(cbo1.ListIndex) =
As you see, the ListIndex is -1.
But, I expect it to be 1
What is wrong in here?
And how can I fix it?
Thanks
Storing its value to the database poses a strange problem.
Let's say I have a combo box with its Style property set to "0 - Dropdown combo"
And I populate it like this:
Code:
Private Sub Form_Load()
......
cbo1.Clear
cbo1.AddItem "One"
cbo1.AddItem "Two"
cbo1.AddItem "Three"
......
End Sub
Code:
cbo1.Text = "Two"
Code:
Private Sub cmdProcList1_Click()
Dim s As String
s = ""
s = s & "cbo1.ListCount = " & cbo1.ListCount & vbCrLf
s = s & "cbo1.ListIndex = " & cbo1.ListIndex & vbCrLf
s = s & "cbo1.Text = " & cbo1.Text & vbCrLf
s = s & "cbo1.List(cbo1.ListIndex) = " & cbo1.List(cbo1.ListIndex) & vbCrLf
s = s & ""
Text3.Text = s
End Sub
Quote:
cbo1.ListCount = 3
cbo1.ListIndex = -1
cbo1.Text = Two
cbo1.List(cbo1.ListIndex) =
But, I expect it to be 1
What is wrong in here?
And how can I fix it?
Thanks