Community discussion forum

Get Current Month Value

Tags: combo, month, vb6 India
  • 3 months ago

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

    Post was edited on 14/08/2009 06:50:53 Report abuse
  • 3 months 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).

We'd love to hear what you think! Submit ideas or give us feedback