I’m trying to create an expiration date using values selected from drop down lists on my web form, however I am unable to concatenate the Month variable value and Year variable value. I get the error: Error Operator ‘&’ is not defined for types ‘String’ and System.Web.UI.WebControls.ListItem’. I have tried to use the “+” also but get the same error.
Here is the code I have:
Dim Month = monthDropDownList.SelectedValue
Dim Year = yearDropDownList.SelectedItem
Dim MonthYear = Month & Year
Dim ExpirationDate As Date = MonthYear
Any help would be greatly appreciated.
You don’t want
SelectedItem. You wantSelectedValue. You should also explicitly declare your variables. You also can’t create a Date in this manner. You need to use integers.As a slight “cleaner” way to do this I would use: