Android Question case select missing parameter

Stern0m1

Member
Licensed User
Im getting "missing parameter"

What am I missing?

Thanks.



Select alarmHours
Case 0
timeset = ("12") & ":" & NumberFormat(alarmMinutes, 2, 0) & " AM"
Case < 12
timeset = (alarmHours ) & ":" & NumberFormat(alarmMinutes, 2, 0) & " AM"
Case 12
timeset = (alarmHours ) & ":" & NumberFormat(alarmMinutes, 2, 0) & " PM"
Case > 12 Then timeset = (alarmHours - 12) & ":" & NumberFormat(alarmMinutes, 2, 0) & " PM"

End Select
 

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
Please use "[ code ]" tags when posting code samples.

From the Beginner's Guide, "Compares a single value to multiple values" you cannot use it compare a range. For an example such as this I would recommend an If-Then-Else syntax. If it were me, I'd use string formatting to build the output.
 
Upvote 0

derez

Expert
Licensed User
Longtime User
You can't write case < 12 or case > 12, only single values or list of values:
case 0,1,2,3,4,5,6,7,8,9,10,11

case 13,14,15,16,17,18,19,20,21,22,23

There is a trick to write cases like you did, using format like this:
select true
case alarmHours= 0

case alarmHours < 12


etc
end select
 
Upvote 0

tigrot

Well-Known Member
Licensed User
Longtime User
In vb.net you should write:
B4X:
Select alarmHours
Case 0
timeset = ("12") & ":" & NumberFormat(alarmMinutes, 2, 0) & " AM"
Case is < 12
timeset = (alarmHours ) & ":" & NumberFormat(alarmMinutes, 2, 0) & " AM"
Case 12
timeset = (alarmHours ) & ":" & NumberFormat(alarmMinutes, 2, 0) & " PM"
Case is  > 12  timeset = (alarmHours - 12) & ":" & NumberFormat(alarmMinutes, 2, 0) & " PM"

End Select
 
Upvote 0
Top