RE: Convert Month number to a string of the Month
Posted: 12/10/2004 3:16:19 PMBy: Comfortably Anonymous
Times Read: 3,107
Likes: 0 Dislikes: 0
Topic: Programming: .NET Framework
OK, that was pretty stupid of me. Just found out that there is a built-in VB.Net function called MonthName() that does the exact same thing and even supports abbreviations... Duh...
Returns a String value containing the name of the specified month.
Public Function MonthName( _
ByVal Month As Integer, _
Optional ByVal Abbreviate As Boolean = False _
) As String
Parameters:
- Month
Required. Integer. The numeric designation of the month, from 1 through 13; 1 indicates January and 12 indicates December. You can use the value 13 with a 13-month calendar. If your system is using a 12-month calendar and Month is 13, MonthName returns an empty string.
- Abbreviate
Optional. Boolean value that indicates if the month name is to be abbreviated. If omitted, the default is False, which means the month name is not abbreviated.
Returns a String value containing the name of the specified month.
Public Function MonthName( _
ByVal Month As Integer, _
Optional ByVal Abbreviate As Boolean = False _
) As String
Parameters:
- Month
Required. Integer. The numeric designation of the month, from 1 through 13; 1 indicates January and 12 indicates December. You can use the value 13 with a 13-month calendar. If your system is using a 12-month calendar and Month is 13, MonthName returns an empty string.
- Abbreviate
Optional. Boolean value that indicates if the month name is to be abbreviated. If omitted, the default is False, which means the month name is not abbreviated.
Rating: (You must be logged in to vote)
Discussion View:
By: Comfortably Anonymous
Times Read: 2,283
Likes: 0 Dislikes: 0
Topic: Programming: .NET Framework
By: Comfortably Anonymous
Times Read: 1,862
Likes: 0 Dislikes: 0
Topic: Programming: .NET Framework
Replies:
RE: Convert Month number to a string of the Month
Posted: 7/28/2005 12:38:35 PMBy: Comfortably Anonymous
Times Read: 2,283
Likes: 0 Dislikes: 0
Topic: Programming: .NET Framework
Anyone have an example of anyone/anywhere who uses a 13 month calendar?
Rating: (You must be logged in to vote)
More stupid bits of code
Posted: 9/15/2005 9:08:59 AMBy: Comfortably Anonymous
Times Read: 1,862
Likes: 0 Dislikes: 0
Topic: Programming: .NET Framework
Here's another example of trying to re-invent the wheel (The NullToString function, not the IsDBNull function, or at least I don't think so anyway :) ). Post your redundant code here too, so that we can all learn from our mistakes
Protected Function IsDBNull(ByVal DBVal) As Boolean
' Checks if value passed from Database is Null
' Returns True if passed value is Null
' Returns False is passed value is Not Null
Return DBVal Is DBNull.Value
End Function
Protected Function NullToString(ByVal DBVal) As String
' Returns empty string is value passed from database is Null
' Converts value to a string if Not Null
' *************************************************************************************
' ** Turns out that if you just use the .ToString method of returned values, it will **
' ** do the same thing automatically. So consider this function deprecated. **
' *************************************************************************************
If IsDBNull(DBVal) Then
Return ""
Else
Return DBVal.ToString
End If
End Function
Protected Function IsDBNull(ByVal DBVal) As Boolean
' Checks if value passed from Database is Null
' Returns True if passed value is Null
' Returns False is passed value is Not Null
Return DBVal Is DBNull.Value
End Function
Protected Function NullToString(ByVal DBVal) As String
' Returns empty string is value passed from database is Null
' Converts value to a string if Not Null
' *************************************************************************************
' ** Turns out that if you just use the .ToString method of returned values, it will **
' ** do the same thing automatically. So consider this function deprecated. **
' *************************************************************************************
If IsDBNull(DBVal) Then
Return ""
Else
Return DBVal.ToString
End If
End Function
Rating: (You must be logged in to vote)