Get Current Month Value

combo , vb6 , month India
  • 11 years ago

    How Can I Get The Current Month Value In Combo Box?

  • 11 years ago

    If you just want the number of the month to play with, you can use ComboBox1.Text = Month(Now())

    If you want the name of the month to appear, you could use code like this: Private Sub CommandButton1_Click() Dim intMonth As Integer Dim txtMonth As String

    intMonth = Month(Now())
    
        Select Case intMonth
            Case 1:
                txtMonth = "January"
            Case 2:
                txtMonth = "February"
            Case 3:
                txtMonth = "March"
            Case 4:
                txtMonth = "April"
            Case 5:
                txtMonth = "May"
            Case 6:
                txtMonth = "June"
            Case 7:
                txtMonth = "July"
            Case 8:
                txtMonth = "August"
            Case 9:
                txtMonth = "September"
            Case 10:
                txtMonth = "October"
            Case 11:
                txtMonth = "November"
            Case 12:
                txtMonth = "December"
        End Select
        ComboBox1.Text = txtMonth
    End Sub
    

    Hope this helps!

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Memory is like an orgasm. It's a lot better if you don't have to fake it.” - Seymour Cray