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?

  • DeveloperStudent12

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

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

    Will return the name



  • rsafier

    Using a Custom DateTime Format Strings try:

    thisMonth1 = thisDate1.ToString("MMMM")



  • marsherfu

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

    And one of us is a woman!



  • KBC

    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).


  • TDerenthal

    thank you

    You guys are awsome :)


  • How to retrieve month name in VB2005?