How to retrieve month name in VB2005?

I'm trying to use this code but it generates an error:

Dim thisDate1 As Date

Dim thisMonth1 As String

thisDate1 = DateString

thisMonth1 = month(thisDate1)

It generates an Error: value of type 'date' cannot be converted to 'integer'

I use similar code retreive current year and it works:

Dim thisDate As Date

Dim thisYear As Integer

thisDate = DateString

thisYear = Year(thisDate)

I want to retrieve current month name and assign it to string variable. How can I do that



Answer this question

How to retrieve month name in VB2005?

  • Ramanakumar

    Month function doesn't return the name of the month, it's return the number of the month from a full date (eg, 16/06/2006).


  • RoGamer

    thank you

    You guys are awsome :)


  • cc212760

    Dim a As String = Date.Now.ToLongDateString.Substring(Date.Now.ToLongDateString.IndexOf(" ") + 1)

    a = a.Substring(0, a.IndexOf(" "))

    Will return the name



  • Jose Carlos T. Santos Junior

    Using a Custom DateTime Format Strings try:

    thisMonth1 = thisDate1.ToString("MMMM")



  • brian185

    "thank you guys" correspond to women as well
  • Chippe01

    And one of us is a woman!



  • How to retrieve month name in VB2005?