Hi,

I need to retrieve string from one form to another form. When I retrieved the latitude and longitude of my current location, I need to use my current latitude and longitude coordinates to link to another map form to display the map with my current location using the coordinates. I am this code, but I'm unable to link the coordinates to the map as I get the data from a string and I think I need to store the string somewhere before I can read the string from another form. How can I solve my problem?

This is my coding:

First form:

Private Sub btnMapIt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMapIt.Click

Dim f As New Map(Latitude, Longitude)
Dim lat, lon As String

If Latitude <> String.Empty And Longitude <> String.Empty Then

txtLat.Text = lat
txtLong.Text = lon

f.Show()

End If

End Sub

Second form:

Public Sub New(ByVal lat As String, ByVal lon As String)

InitializeComponent()

If (lat = String.Empty Or lon = String.Empty) Then
Me.Dispose()
End If

Try

Dim queryAddress As New StringBuilder()

If lat <> String.Empty AndAlso lon <> String.Empty Then
queryAddress.Append("http://maps.google.com/?q=" & lon & "," & lat)
End If

Try this:
form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If txtLat.Text <> String.Empty And txtLong.Text <> String.Empty Then
            Dim f As New map(txtLat.Text, txtLong.Text)
            f.Show()
        End If
    End Sub

form2

Public Sub New(ByVal lat As String, ByVal lon As String)
        InitializeComponent()
        If (lat = String.Empty Or lon = String.Empty) Then
            Me.Dispose()
        Else
            TextBox1.Text = lat
            TextBox2.Text = lon
        End If
    End Sub

Thanks wayne!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.