Do While Not(IsValid)
Wait For (mainDialog.ShowCustom(pnlPrefs, obOK, "", obCancel)) Complete (dlgResult As Int)
Select dlgResult
Case DialogResponse.POSITIVE
' Validate the accepted values
IsValid = True
Dim tDistance As Int
Try
tDistance = txtPrefAutoCollectionDistance.Text
If tDistance < Starter.MinDistance Or tDistance > Starter.MaxDistance Then
' The range is outside the min/max - let the user know
UI.ShowToastMessage(obInvalidDistance, True, UI.TOAST_ERROR, UI.ICON_ERROR)
IsValid = False
' Continue ' <<<<<<<< not working as expected
End If
Catch
Log(LastException)
End Try
Dim tTime As Int
If IsValid Then
Try
tTime = txtPrefAutoCollectionTime.Text
If tTime < Starter.MinTime Or tTime > Starter.MaxTime Then
' The range is outside of the min/max - let the user know
UI.ShowToastMessage(obInvalidTime, True, UI.TOAST_ERROR, UI.ICON_ERROR)
IsValid = False
End If
Catch
Log(LastException)
End Try
End If
If IsValid Then
' Save the new values
Starter.AppConfig.Put(Starter.obAutoCollectionDistance, tDistance)
Starter.AppConfig.Put(Starter.obAutoCollectionTime, tTime)
' all is good - make the user feel all warm and fuzzy
UI.ShowToastMessage(obUpdatedPreferences, True, UI.TOAST_SUCCESS, UI.ICON_TICK)
End If
Case Else
' Cancellation from the user is Valid - nothing is updated
IsValid = True
End Select
Loop