Re: Dates with the Macro by Helmut
Helmut
Wed Oct 04 11:05:47 CDT 2006
Hi,
have a look at this one:
Private Sub CommandButton1_Click()
Dim sTmp1 As String
Dim sTmp2 As String
Dim TB2 As Date
TB2 = TextBox1.Value
TextBox1.Value = Format(TB2, "dd mmmm yyyy")
sTmp1 = Left(TextBox1.Value, 2)
sTmp2 = Right(TextBox1.Value, Len(TextBox1.Value) - 2)
Select Case sTmp1
Case "01", "21", "31": sTmp1 = sTmp1 & "st"
Case "02", "22": sTmp1 = sTmp1 & "nd"
Case "03", "23": sTmp1 = sTmp1 & "rd"
Case Else: sTmp1 = sTmp1 & "th"
End Select
TextBox1.Value = sTmp1 & sTmp2
End Sub
Note: I tested with textbox1,
and allowing input of a date as string
is not a good idea after all.
--
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"