To avoid repeating the code you can create this sub:
Sub IsInternetAvailable As HttpJob
Dim j As HttpJob
j.Initialize("", Me)
j.Download("https://www.google.com") 'or better your own link
Return j
End Sub
Now you can write wherever you want to check:
Wait For (IsInternetAvailable) JobDone(j As HttpJob)
If j.Success Then
'internet is available
End If
j.Release