Tuesday, October 19, 2010

Visual Basic 6 Transfer Text from Text Box to HTML Text Area

,
In order to transfer text from Visual Basic 6 text box to HTML text area, you need to view first the HTML source of the web page. I have created a simple web page with a text area and a button assuming that this is the web page we want to manipulate. You can download the whole program here. After downloading  extract the file > open the index.html > right Click on the web page and you will see a menu, select “View Page Source”.


On the page source, you will see the HTML code of the web page. The next thing you need to do is to find the name of the text area.


Based on the image, the name of the text area on the web page I have created is “content”.

Open your Visual Basic 6 editor and create a Standard EXE project. On the menu bar, click Projects > Components or you can press CTRL+T to open the components window > check the “Microsoft Internet Controls” > click Apply.


After clicking the apply button, you will see a web browser icon.


On your VB 6 editor, create an interface similar to this:


Name the button as “Command1”, Text box as “Text1”, and the web browser as “WebBrowser1”. Click the “View” button:


Copy and Paste this Code:

Private Sub Command1_Click()
WebBrowser1.Document.All("content").Value = Text1.Text
End Sub

Private Sub Form_Load()
WebBrowser1.Navigate ("Put your URL here or the URL of the web page you have created")
End Sub

If we interpret the code, it says whenever the application starts, the WebBrowser1 will navigate to the URL I specified ex. www.google.com or the HTML file I have created in my case my HTML file is located at:

file:///C:/Documents%20and%20Settings/Mamboo%20Jamboo/Desktop/transfer%20text%20to%20html%20textbox/index.html

so my code goes this way:

Private Sub Form_Load()
WebBrowser1.Navigate ("file:///C:/Documents%20and%20Settings/Mamboo%20Jamboo/Desktop/transfer%20text%20to%20html%20textbox/index.html")
End Sub

Everytime the “Command1” button is press the text area with an id name “content” will get all the text from the Visual Basic text box. To make it simple, the idea goes like this:

HTML <---------------------------------- Visual Basic 6
TextArea(“content”) gets the value of TextBox(“Text1.Text”)

0 comments to “Visual Basic 6 Transfer Text from Text Box to HTML Text Area”

Post a Comment

 

Topic Central Copyright © 2011 -- Template created by O Pregador -- Powered by Blogger