locked
DayOfWeek as integer RRS feed

  • Question

  • User-1783733874 posted

    Hello. I can't seem to get something that seems pretty simple to work. I have a dropdown that has options like 'Every Monday and Tuesday' which would have a value of '12' (1 for Monday and 2 for Tuesday). In vb I then have a variable (sd as Date). What I need to do is see if the DayOfWeek for the variable is in the dropdown selected value (sort of like 'dropdown.selectedvalue.indexof(sd.dayofweek)').  Indexof returns either Nothing or an integer correct? Below is the specific code

    Dim dow As Integer = sd.DayOfWeek
              If (dropdown.SelectedValue.IndexOf(dow.ToString) = Nothing) Then
    Wednesday, August 3, 2011 3:40 PM

Answers

  • User653228039 posted

    I'm pretty sure IndexOf always returns an int.  -1 if it is not in there.  Try to check if it is >= 0

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 3, 2011 4:48 PM

All replies

  • User653228039 posted

    I'm pretty sure IndexOf always returns an int.  -1 if it is not in there.  Try to check if it is >= 0

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 3, 2011 4:48 PM
  • User-1783733874 posted

    Ha! That was it. Thanks alot Ace!

    Thursday, August 4, 2011 8:17 AM