MsgBox

Hi,

In Button action event I have write the below code, while compile the same application through the error as “There is more than one item with this name and in’s not clear to which this refer”

Dim today As New Date
Dim year As Variant
year = today.Year
year = Right(year,2)
MsgBox(today)

Kindly advise the same.

MsgBox str(today)

or

MsgBox (today.ShortDate)

or

MsgBox (today.LongDate)

[quote=261250:@Pathma Mu]
year = Right(year,2)
MsgBox(today)[/quote]

Year is an Integer, you are treating it as a string. Hence the error.

This should work :

year = Right(str(year),2) MsgBox(today)