4 Replies - 3939 Views - Last Post: 15 August 2013 - 04:15 AM Rate Topic: -----

#1 brerallia  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 146
  • Joined: 21-January 13

How to clear the selected value of a combobox?

Posted 12 August 2013 - 05:12 AM

Hi everyone i am currently on vb6 advanced and i have some trouble dealing with comboboxes...

so here it goes:

my program is about finding out the season in a particular date in which the user will enter...
the objects are combobox, a dropdown tha has a list of months -- january, february ... etc
and a text box in which the user will input the date...
so when the user selects may and enters a date which is 6 then it will calculate as "the season for this month is Spring"... -- so in this part, analyzation, i got the code correct...so i dont have any problems dealing with the flow of the calculation...
there is also a clear button in which the after the user uses the she will click the clear button and the selected value in the combobox will be erased....
i dont need to delete the list of the combobox but to deselect the past selected month...

have you notice that when you run the program in vb the combobox does some blue color and that it is not selected?? well, that is what i mean..

ANY HELP WILL BE APPRECIATED..

Is This A Good Question/Topic? 0
  • +

Replies To: How to clear the selected value of a combobox?

#2 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3522
  • View blog
  • Posts: 12,029
  • Joined: 12-December 12

Re: How to clear the selected value of a combobox?

Posted 12 August 2013 - 06:46 AM

I cannot follow your description (is there a question in there?) but based simply on your title, and given that I don't have VB6 to test, I would guess that you can set:

theComboBox.ListIndex = -1

to de-select an item in the combobox.

http://visualbasic.f...b6/lesson9.html
Was This Post Helpful? 1
  • +
  • -

#3 brerallia  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 146
  • Joined: 21-January 13

Re: How to clear the selected value of a combobox?

Posted 14 August 2013 - 03:57 AM

View Postandrewsw, on 12 August 2013 - 06:46 AM, said:

I cannot follow your description (is there a question in there?) but based simply on your title, and given that I don't have VB6 to test, I would guess that you can set:

theComboBox.ListIndex = -1

to de-select an item in the combobox.

http://visualbasic.f...b6/lesson9.html


YAY!!! thats what i mean!! thank you it works... i will give you a thumbs up on it!!!
i thought it was clear.. but when i use clear and i click the button the combobox clears all the data in there... thank you for this idea.. anyway care to explain for me to understand why is it -1??
Was This Post Helpful? 0
  • +
  • -

#4 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3522
  • View blog
  • Posts: 12,029
  • Joined: 12-December 12

Re: How to clear the selected value of a combobox?

Posted 14 August 2013 - 05:30 AM

In VB6 a ListIndex of 0 would select the first item in the ComboBox, 1 the second. They chose -1 as the value that represents "nothing selected".

http://msdn.microsof...2(v=vs.60).aspx

This post has been edited by andrewsw: 14 August 2013 - 05:33 AM

Was This Post Helpful? 1
  • +
  • -

#5 brerallia  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 146
  • Joined: 21-January 13

Re: How to clear the selected value of a combobox?

Posted 15 August 2013 - 04:15 AM

View Postandrewsw, on 14 August 2013 - 05:30 AM, said:

In VB6 a ListIndex of 0 would select the first item in the ComboBox, 1 the second. They chose -1 as the value that represents "nothing selected".

http://msdn.microsof...2(v=vs.60).aspx


wow!! thanks, now i know.. so it is like an index number which starts at 0... i understand now.. thank you.. double thumbs up.. :bigsmile: :bigsmile:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1