Convert Month number to Month name [Resolved]

Posted by Pallubhosale under VB.NET on 1/30/2014 | Points: 10 | Views : 2543 | Status : [Member] | Replies : 3
Hi,
I want to conver month number to month name.

when we enter 2 on txtbox it will display Feb
And When we enter January it wil display JAN

Thanks

Pallavi


Responses

Posted by: kgovindarao523-21772 on: 1/30/2014 [Member] [MVP] Bronze | Points: 50

Up
0
Down

Resolved
Hi,
In text change event write below code.

Dim thisMonth As Integer 
Dim name As String
thisMonth = Convert.toInt32(txtMonth.Text)
' Set Abbreviate to True to return an abbreviated name.
name = MonthName(thisMonth, True)
' name now contains "Apr".
txtMonth.Text=name


Thank you,
Govind

Pallubhosale, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Prabhukiran345 on: 1/30/2014 [Member] Starter | Points: 25

Up
0
Down
Dim Month = textboxID.Text; // Storing Entered Month 
Dim MonthName as DateTime = new DateTime(2014,Month,01) //Get Date time of Given Month
textboxID.Text = MonthName.ToString("MMM")// Displays month of given number as string in textbox.


Thanks,
Prabhu Kiran Bommareddy

Pallubhosale, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pallubhosale on: 2/3/2014 [Member] Starter | Points: 25

Up
0
Down
Hi,
Hi Govind your code is running well when enter the month number. but what if user enter month name
it wil take as it is



Pallavi

Pallubhosale, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response