我想在textbox1中插入一个像“feb-2016”这样的日期,并记住变量“data”,就像我插入它一样。
Private Sub importa_buton_Click()
Dim data As Date
Dim luna As String
Dim anul As Integer
data = Analiza_Date.TextBox1.Value
TextBox1.Value = Format(data, "mmm-yyyy")
luna = month(data)
anul = year(data)
msgbox data
msgbox luna
msgbox anul
上面的代码msgbox data
的输出是01.02.2016,我想显示输入“feb-2016”
答案 0 :(得分:1)
您可以使用这样的两个函数MonthName
和Year
构建一个字符串
Dim str As String
str = MonthName(date, TRUE) & "-" & Year(date)
其中date
是您的约会对象。如果MonthName
中的第二个参数为TRUE
,则返回缩写而不是完整的月份名称。
答案 1 :(得分:1)
使用以下代码保存:
data As Date
,luna As String
和anul As Integer
Private Sub importa_buton_Click()
Dim data As Date
Dim luna As String
Dim anul As Integer
data = Analiza_Date.TextBox1.value
TextBox1.value = Format(data, "mmm-yyyy")
luna = Format(data, "mmm")
anul = Year(data)
MsgBox luna & "-" & anul
MsgBox luna
MsgBox anul
End Sub