?
Solved

2 questions about ComboBox

Posted on 2004-10-31
3
Medium Priority
?
201 Views
Last Modified: 2010-04-23
Hi,
Let's say that I have two comboboxes named cboDay and cboMonth.

1) Let's say i want to type something into my combobox and when i click enter, i want that text that i typed to be automatically added to the list. So the next time i drop down my combobox, i want that text to be in the list.
I already set dropDownStyle to DropDown. If i have to type a code for that, could you please tell me in what procedure to write it?
cboDay_KeyPress? cboDay_Enter?

2)cboMonth has months of the year from 1 to 12. CboDays initially has numbers from 1 to 31. But not all the months has same number of days.
How will i make it so that if user clicks 2 from cboMonth, days in cboDay will remove 30 and 31 from the list? (February may have 29 days but not 30 and 31.) And when user clicks 3 from cboMonth , 30 and 31 will be added to cboDays list.
Is it gonna be something like,
 if cboMonth.selectedIndex = 1 then
      cboMonth.Items.Remove(29)
      cboMonth.Items.Remove(30)
 endIf

Thanks
0
Comment
Question by:aeusta
  • 2
3 Comments
 
LVL 2

Expert Comment

by:koolnurd
ID: 12461280
A>>>

At KeyPress Check for

e.KeyChar.GetHashCode  it is 851981 for Enter.

B>>>

You Add the days at run time only first check the month and then add item in the combo through a loop.

create three conditions for 28 , 30, 31  Also 29 if consider leep year .



0
 

Author Comment

by:aeusta
ID: 12461350
Part A works, but can you be more spesific on part b?
What is the procedure to create those conditions? It would be nice if you could write the exact code.
Thanks
0
 
LVL 2

Accepted Solution

by:
koolnurd earned 600 total points
ID: 12461418
try like this way


Dim i As Integer
        Select Case (cboMonth.Text)
            Case 1, 3, 5, 7, 8, 10, 12
                For i = 1 To 31
                    cboDay.Items.Add(i)
                Next
            Case 2
                For i = 1 To 28
                    cboDay.Items.Add(i)
                Next
            Case 4, 6, 9, 11
                For i = 1 To 30
                    cboDay.Items.Add(i)
                Next
            Case Else

        End Select
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
SQL Database Recovery Software repairs the MDF & NDF Files, corrupted due to hardware related issues or software related errors. Provides preview of recovered database objects and allows saving in either MSSQL, CSV, HTML or XLS format. Ensures recov…

594 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question