Hello there... I use these codes to print out the location of the device. The problem is, the value is not appearing in the textbox (txtLatitude) when the form is loaded. But when I replace the textbox with MsgBox(Latitude) it works perfectly. I just don't understand why the value is not appearing in the textbox. Any suggestion? Thank you...
Imports System.Device.Location Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim myLocation As New Form1() myLocation.GetLocationDataEvent() End Sub Private WithEvents watcher As GeoCoordinateWatcher Public Sub GetLocationDataEvent() watcher = New System.Device.Location.GeoCoordinateWatcher() AddHandler watcher.PositionChanged, AddressOf watcher_PositionChanged watcher.Start() End Sub Private Sub watcher_PositionChanged(ByVal sender As Object, ByVal e As GeoPositionChangedEventArgs(Of GeoCoordinate)) PrintPosition(e.Position.Location.Latitude, e.Position.Location.Longitude) ' Stop receiving updates after the first one. watcher.Stop() End Sub Private Sub PrintPosition(ByVal Latitude As Double, ByVal Longitude As Double) txtLatitude.text = Latitude End Sub End Class