Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 22038

[RESOLVED] Hi, Need some help adding code to my web browser

$
0
0
Hi, when ever I open up an address like msn.com or yahoo.com, google.com I get a message that says there was a script error here is my code, oh and I want to make it that my images of refresh and exit and search image they dong get big like the browser its self and the text box to type a address in, so is the a way to make it get grow with the browser and i want the images to get centered with the browser if that can be done.. thanks:wave:

Code:






Private Sub Form_Load()
'Form_Load is in every VB program

Text1.Text = "http:\\www."

WebBrowser.Navigate "http:\\www."

End Sub

Private Sub Form_Resize()

On Error Resume Next 'the most common error handler in vb

If WebBrowser.Left = 0 Then 'if the webBrowser's position is 0 then

End If
'its kind of confusing here, try playing with the number values
WebBrowser.Width = Me.Width - 200 - WebBrowser.Left 'me.width is refering to the webBrowser
WebBrowser.Height = Me.Height - WebBrowser.Top - 1000 'this subtracts one thousand fromt he form's window top.

End Sub



Private Sub Image1_Click()
If Not Left(Text1.Text, 11) = "http://www." Then
End If
WebBrowser.Navigate Text1.Text


End Sub

Private Sub Image3_Click()
Timer1.Enabled = True 'this calls Timer1 to begin.

End Sub

Private Sub Image4_Click()
End

End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
'this command is more in depth and takes a while to grasp
'Its the Keyascii that is vital

If KeyAscii = 10 Then
'if the user strikes the Enter key

If Not Left(Text1.Text, 11) = "http://www." Then
'the if not line is saying to Text1, that if http://www.
'is not included then include it into webBrowser.

Text1.Text = "http://www." + Text1.Text + ""
'so http://www. plus whatever the user types and insted of
'hitting enter they hit our Text1_KeyPress, the Enter key, then
'it carries the text to the webBrowser.

WebBrowser.Navigate Text1.Text 'this sets up webBrowser to navigate to whatever Text1 is.
End If
End If

If KeyAscii = 13 Then 'if user hits the enter key

WebBrowser.Navigate Text1.Text 'navigates the webBrowser to whatever Text1 is.

End If

End Sub

Private Sub Timer1_Timer()

WebBrowser.Refresh 'this means to refresh the website  .refresh is usful.

Timer1.Enabled = False 'sets the timer1 to false to turn it off
End Sub

'this is hard to grasp because the title is changing to something we don't know.
'The "ByVal" makes "Text" and "As String" stores the data(the data is the websites title), in "Text"
Private Sub WebBrowser_TitleChange(ByVal Text As String) 'ByVal makes "Text" variable.
'and "As String" is how it is stored.

Me.Caption = "The web address:    -    " + Text ' this "Text" does not acctually mean writing text.
'Me.Caption is refering to the webBrowser's titlebar text
'the + "Text" means plus the webBrowser's text. "ex: The web address: - ass.com"

End Sub


Viewing all articles
Browse latest Browse all 22038

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>