select case not working

  1. 5 days ago

    Hello.

    Little issue here, that I should be able to figure out, but can't.

    I want to select a tab on a TabPanel by the day, so I did the following:

    dim myDay as new Date
    MessageBox "The Day is "+(myDay.DayOfWeek.ToString) // just for testing
    
    select case myDay
    Case 0
    Messagebox "Monday"
    Case 1
    Messagebox "Tuesday"
    Case 2
    Messagebox "Wednesday"
    Case 3
    Messagebox "Thursday"
    Case 4
    Messagebox "Friday"
    Case 5
    Messagebox "Saturday"
    Case 6
    Messagebox "Sunday"
    end select

    The myDay (as of today) shows 5 for Thursday

    When I try and run my program, I get the error message

    Undefined operator Type date does not define "=" with type int64.

    Any ideas?

    Regards

    Thanks Mr. Parnell! A cookie for you... delivered via ALOT of social distancing!

    :-D

    Regards

  2. Tim P

    May 21 Testers, Xojo Pro Rochester, NY

    You're trying to select the state of myDate, not the DayOfWeek property. One small update should get you moving again:

    select case myDay.DayOfWeek
  3. Michael C

    May 21 Answer

    Thanks Mr. Parnell! A cookie for you... delivered via ALOT of social distancing!

    :-D

    Regards

  4. Alberto D

    May 21 Testers, Xojo Pro Austin, Texas

    The docs say DayOfWeek values are 1-7 Sunday-Saturday.

  5. Hi Alberto.

    Yeah. I read that too... so I had to do a little simple math to make things work out.

    Regards

or Sign Up to reply!