Next and Back buttons...again.

NDaphid
07-17-2003, 09:21 PM
OK...after several alterations with help, I've arrived at the following code...still will not work...what's wrong now?

Example:

Private Sub Form_Load()

End Sub

Dim urls As String
Dim current As Integer
urls(0) = "www.google.com"
urls(1) = "www.aol.com"
urls(2) = "www.hp.com"
urls(3) = "www.yahoo.com"

Sub Command1_Click() 'Next button
If current < 4 Then current = current + 1
WebBrowser1.navigate urls(current)
End Sub

Sub Command2_Click() 'Back button
If current > 0 Then current = current - 1
WebBrowser1.navigate urls(current)
End Sub

What I'm getting is: Compile error. Sub or function not defined...then in the code: urls is highlighted.

Any help would be appreciated...thanks!

Squishy
07-17-2003, 10:47 PM
This works...

Dim Current As Integer

Function URL(Page As Integer) As String
Select Case Page
Case 0
URL = "www.google.com"
Case 1
URL = "www.aol.com"
Case 2
URL = "www.hp.com"
Case 3
URL = "www.yahoo.com"
End Select

End Function

Sub Command1_Click() 'Next button
If Current < 4 Then
Current = Current + 1
WebBrowser1.Navigate URL(Current)
'better to put this in the if statement too...to keep the browser from reloading the current page
End If

End Sub

Sub Command2_Click() 'Back button
If Current > 0 Then
Current = Current - 1
WebBrowser1.Navigate URL(Current)
End If

End Sub

Private Sub Form_Load()
WebBrowser1.Navigate URL(Current)

End Sub

NDaphid
07-18-2003, 07:00 AM
Thanks alot...works great!

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum