Null pointer error using a timer to Httprequest

beto1062

Member
Licensed User
Longtime User
Hi,
I´m starting with B4A.
I started modifying the Currency Calculator.
In that app the HttpRequest is called from a button with a code like:

Sub btn_Click
Dim btn As Button
btn = Sender 'Fetch the actual button that raised this event.
CurrentTask = btn.Tag 'Take the object from its Tag property.
Dim request As HttpRequest
request.InitializeGet(URL)
request.Timeout = 10000 'set timeout to 10 seconds
If HttpClient1.Execute(request, 1) = False Then Return
ProgressDialogShow("Calling server...")
End Sub

And works OK.
I´ve added a Timer to do the same Httprequest every 1 second with:

Sub Timer1_Tick
Dim request As HttpRequest
request.InitializeGet(URL)
request.Timeout = 10000 'set timeout to 10 seconds
If HttpClient1.Execute(request, 1) = False Then Return
ProgressDialogShow("Calling server...")
End Sub

The same code but the 'Take the object from its Tag property.
And when its fired it trought a Null Pointer error.

What am I doing wrong?
Thanks
 
Top