• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 177
  • Last Modified:

display website

How can I display a website through VB a user enters into a text box. Also is it possible to return search results using any search engine, yahoo, google, on a word the user enters into another text box.
1 Solution
In VB you will find web objects. Click on Project/Components. Click on Microsoft Internet Controls. Also check out Microsoft Internet Transfer Control.

You can do this in 2 ways:

1) Simple

a)Add Project component Microsoft Internet Controls

b)Open tool box then click on the Globe (Webbrowser Control) and place on your form.

c)Add the following:

Private Sub Form_Load()

WebBrowser1.Navigate2 "http://www.microsoft.com"

End Sub

d)Hit Run!

You get the web-site on your form.

So you can add a textbox and a Go Command button:

Sub cmdGo_Click()
WebBrowser1.Navigate2 text1
End Sub

2) Complex

Add the project component "Microsoft Internet Transfer Control"

dim url as string
dim PageData as string
dim ok

ok = DownloadFileOK(url, pagedata)
if not ok then
  msgbox "could not get data from site"
  label1.caption = PageData
end if

Now de-code the htlm in pagedata and display details ina picture box (thats the hard bit).

Have fun.....

Function DownloadFileOK(url As String, DataReturned As String) As Boolean

Dim b() As Byte
Dim bc As Long
Dim bl As Long

Dim purl As String

purl = url

On Error Resume Next
b = Inet.OpenURL(purl, icByteArray)

If Err.Number = 0 Then
   DownloadFileOK = True
   bl = UBound(b)
   DataReturned = Space$(bl + 1)
   For bc = 0 To bl
       Mid(DataReturned, bc + 1, 1) = Chr$(b(bc))
   Next bc
   DownloadFileOK = False
   ErrorNumber = Err.Number
   ErrorReason = Err.Description
End If

Erase b

End Function

wsaAuthor Commented:
Thanks inthedark the simplified solution works great. Do you know the best way to perform a search on a word the user enters into the text box, using yahoo, etc?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now