I want to insert into textbox1 a date like "feb-2016" and to memorize in a variable "data" like i insert it.
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
With the code above the output for msgbox data
is 01.02.2016 and i want to display like input "feb-2016"
You can build up a string with the two functions MonthName
and Year
like this
Dim str As String
str = MonthName(date, TRUE) & "-" & Year(date)
where date
is your date. If the second argument in MonthName
is TRUE
then the abbreviation and not the full month name is returned.
Use the following code to save:
data As Date
, luna As String
and 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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.