-
I have this code piece to try and convert a month in numbers to the actual month like 11/ would be november. But I get a blank msgbox when I try this code and I can not figure out why! thanks for any help!
Dim strdate As String
Dim strmonth As String
Dim theday As String
Dim str2 As String
Dim strday As String
Dim chkmonth As String
strdate = Text1.Text
If Left$(strdate, 3) = "/" Then
Select Case Mid(Text1.Text, 1, 2)
Case "10"
str2 = "October"
Case "11"
str2 = "November"
Case "12"
str2 = "December"
End Select
strmonth = str2
End If
MsgBox strmonth
-
well the proble might lie in either ur if statement or at the end
If Left$(strdate, 3) = "/" Then
Select Case Mid(Text1.Text, 1, 2)
Case "10"
str2 = "October"
Case "11"
str2 = "November"
Case "12"
str2 = "December"
End Select
strmonth = str2
End If
MsgBox strmonth
that last line is saying that if the months don't fall between oct or dec then give a message box of strmonth ...
but no where on ur code is strmonth set to anything ...
maybe u meant to put: msgbox str2 ???
-
The reason it was showing nothing was because left$ was returning "dd/" and not just /.
The code below works
Dim temp As String
strdate = Text1.Text
temp = Mid(strdate, 4, 2) ' Starts at position 4 in the
' string and returns the next 2
' chars i.e mm out of dd/mm/yy
Select Case temp
Case "10"
str2 = "October"
Case "11"
str2 = "November"
Case "12"
str2 = "December"
End Select
strmonth = str2
MsgBox strmonth
Hope it helps
H. :)
-
How about monthname function? It even returns the name in your language you've set on your comp:
Code:
Msgbox monthname(month(strdate ))
-
Thanks everyone I now can make this function shorter and actually work!
-
<?>
Code:
'easier this way.
Private Sub Command1_Click()
MsgBox Format(Text1.Text, "mmmm")
End Sub
Private Sub Form_Load()
Text1 = "2000/11/19"
End Sub