Android Question FirstTime and variables

hugorinen

Member
Licensed User
Longtime User
Hi !

I'm running b4a 3.2, and I've got a problem when I start a non-main activity for the second time (FirstTime = False). The log is attached. Code is very simple.

I parse two dates, then I use DateUtils.PeriodBetween. The FirstTime it works, the second times it fails, the third times it works, the forth it fails etc...


Thanks in advance
 

Attachments

  • pb.PNG
    pb.PNG
    33.9 KB · Views: 187
Last edited:

HotShoe

Well-Known Member
Licensed User
Longtime User
Not sure I follow, but it sounds like you are using variables that are declared in sub Globals instead of declaring them in sub Process_Globals. hard to say without seeing the project or at least the Activity_Create with notes on where things are declared. It's just a guess otherwise.

--- Jem
 
Upvote 0

hugorinen

Member
Licensed User
Longtime User
Thanks for your response,

Variable occurence is declared in Sub Globals but its value is correct.
I tried to declare it in Sub Process Globals, same problem.
The important thing is that occurence has the same value (shown in the debugger) but DateUtils.PeriodBetween doesn't return the same value.

Here's my code,

B4X:
DateTime.DateFormat = "dd/MM/yyyy"
Dim occurence_() As String = sf.Split2(occurence,";") 'occurence is like "dd/MM/yyyy;dd/MM/yyyy"
Log("différence entre " & occurence_(0) & " et " & occurence_(1) & ":" & DateUtils.PeriodBetween(DateTime.DateParse(occurence_(0)),DateTime.DateParse(occurence_(1))))
 
Last edited:
Upvote 0

eps

Expert
Licensed User
Longtime User
Any code?

I suspect that you are doing something using FirstTime is False or True and this is affecting the processing.
 
Upvote 0

hugorinen

Member
Licensed User
Longtime User
I checked and there's absolutely nothing related to FirstTime variable, except the error in the calculation which happens only one other time.
 
Last edited:
Upvote 0

eps

Expert
Licensed User
Longtime User
I would check some of the functions you are using sometimes they adjust the type of the variable being cast. I would check the data being passed in to these, but as you've not given any code all people can do is second guess the issue.
 
Upvote 0
Top