I am wanting to use the FindNextTime sub mentioned here to pass in values from a list as the parameter (rather than hardcoded values). I tried to give it a string but it won't accept it, how should I do it?
B4X:
Dim strTimes As String
strTimes = 12+01/60
Dim strTimes2 As String
strTimes2 = 17+12/60
Dim strFinal As String = strTimes & "," & strTimes2
Dim t As Long = FindNextTime(strFinal)
And I'm getting: java.lang.NumberFormatException: For input string: "12.016666666666667,17.2"
Thanks, but what about a case where the number of parameters (strTimesX) is unknown? I can't see a way to do a loop and build up a variable to pass through?
Bear in mind that you can pass either a list or an array to the function.
An array cannot be extended once Dimmed, so here you'd be better using a list.
B4X:
Dim TimeList As List
TimeList.Initialize
Dim ClassStartTime as Double
For ClassStartTime = 9 to 15+21/60 Step 55/60 'test data = school class start times every 55 minutes from 9am to 3:21pm
TimeList.Add(ClassStartTime)
Next
Log(TimeList) 'so we can see what's going on
Dim t As Long = FindNextTime(TimeList)
Bear in mind that you can pass either a list or an array to the function.
An array cannot be extended once Dimmed, so here you'd be better using a list.
B4X:
Dim TimeList As List
TimeList.Initialize
Dim ClassStartTime as Double
For ClassStartTime = 9 to 15+21/60 Step 55/60 'test data = school class start times every 55 minutes from 9am to 3:21pm
TimeList.Add(ClassStartTime)
Next
Log(TimeList) 'so we can see what's going on
Dim t As Long = FindNextTime(TimeList)