Option Explicit
Sub Demo()
Dim Prompt As String
Dim Recipient As String
Dim MonthsFrench() As Variant
Dim Today As Date
Today = Now()
MonthsFrench = VBA.Array("", "Janvier", "Févier", "Mars", "Avril", "Mai", "Juin", _
"Juillet", "Auguste", "Septembre", "Octobre", "Novembre", "Décembre")
' I have used VBA.Array so lower bound is zero regardless of option base setting
Debug.Print Format(Today, "d mmmm yyyy")
Debug.Print Format(Today, "mmmm d, yyyy")
Debug.Print Day(Today) & " " & MonthsFrench(Month(Today)) & " " & Year(Today)
Do While True
If Recipient = "" Then
Prompt = "Recipient name?"
Else
Prompt = "Last recipient, " & Recipient & " preferred date is "
Select Case Recipient
Case "Jesse"
Prompt = Prompt & Format(Today, "mmmm d, yyyy")
Case "John"
Prompt = Prompt & Format(Today, "d mmmm yyyy")
Case "Jacque"
Prompt = Prompt & Day(Today) & " " & MonthsFrench(Month(Today)) & " " & Year(Today)
Case Else
Prompt = "Last recipient not known"
End Select
Prompt = Prompt & vbLf & "Next recipient name?"
End If
Recipient = InputBox(Prompt)
If Recipient = "" Then
Exit Sub
End If
Loop
End Sub
1 回答
对不起,我没有在评论中明确说明 .
当您在格式中包含“$ -409”时,您决定需要美国格式日期 . Excel可以帮助您创建美国格式的日期,但它无法帮助您确定所需的格式日期 .
是你必须确定杰西获得美国约会,约翰获得英国约会,雅克获得法国约会 . 做出决定后,VB会在格式化日期时接受国家/地区代码,但我不相信VBA会提供任何此类功能 . 由于您只有两个区域设置,我建议您自己进行转换 .