0

I am trying to code this but I find it hard to solve it. I'll just show you the image of the scenario.

enter image description here

html code:

<tr>
    <td>Lat</td>
    <td><input type="text" size="20" id="dd_lat" value="38.898556" runat="server"></td>
</tr>
<tr>
    <td>Long</td>
    <td><input type="text" size="20" id="dd_long" value="-77.037852" runat="server"></td>
</tr>

VB.NET code

Private Sub Button1_ApplyCoordinates_Click(sender As Object, e As EventArgs) Handles Button1_ApplyCoordinates.Click
   Mapping.TextBox2_Latitude.Text = WebBrowser1.Document.GetElementById("dd_lat").ToString
   Mapping.TextBox1_Longhitude.Text = WebBrowser1.Document.GetElementById("dd_long").ToString
End Sub
8
  • It sounds as though you may want to look into ASP.NET. There are a number of tutorials on asp.net and all over the web. VB.NET can be used as the server-side language of an ASP.NET application, and ASP.NET WebPages uses methods with signatures similar to the one you've described. Commented Jun 3, 2016 at 12:22
  • 1
    is there an actual question? I am assuming that this is ASP.net correct? Commented Jun 3, 2016 at 12:25
  • I don't want to use asp.net I just want to pass the values from html to vb.net. The question here is, is that possible without using asp.net? Commented Jun 3, 2016 at 12:38
  • You want to enter values in a browser somewhere, but then somehow copy that into a WinForms app? Is that your question? If so, the answer is 'not really'. You could host an HTML application within your VB.NET app (applications like VS Code run in this way) and that would allow you to read values from the hosted page, or I suppose you could use automation of the browser from your VB.NET app to read a value of a textbox on a web page. Commented Jun 3, 2016 at 12:38
  • The OP is using the WebBrowser winforms control based on the code in his question i.e. ... = WebBrowser1.Document.... The tags on the question need to updated. Commented Jun 3, 2016 at 12:41

1 Answer 1

1

The ToString method is just going to return the type of the object return by GetElementById and not the value of the input in the HTML. To get the latitude, or whatever, use the GetAttribute method and pass in "value". So your Sub could be coded as:

Private Sub Button1_ApplyCoordinates_Click(sender As Object, e As EventArgs) Handles Button1_ApplyCoordinates.Click
   Mapping.TextBox2_Latitude.Text = WebBrowser1.Document.GetElementById("dd_lat").GetAttribute("value")
   Mapping.TextBox1_Longhitude.Text = WebBrowser1.Document.GetElementById("dd_long").GetAttribute("value")
End Sub
Sign up to request clarification or add additional context in comments.

1 Comment

Wow, this is amazing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.