moving to the next array?
Hi All,
I am still new to VB, so I need a little help please. I am trying to move to the next array in the below code. i know its very simple, but once the "clickbutton" check has been completed for varArray(0) , how do i move to varArray(1)?
Any help would be grateful.
Thanks.
Dim varArray(0 To 1) As Variant
varArray(0) = "http://www.bbc.co.uk"
varArray(1) = "http://www.vbforum..com"
GoToPage (varArray(0))
ClickButton ""
If ClickButton = True Then
WriteToLog "button found"
End If
End Sub
Re: moving to the next array?
im not sure what your trying to do...
but just go to the next one?
GoToPage (varArray(1))
ClickButton ""
If ClickButton = True Then
WriteToLog "button found"
End If
for you could use a loop
VB Code:
For x = 0 to 1 ' or if u dont know how many are in your array
'For x = 0 to ubound(varArray)
GoToPage (varArray(x))
ClickButton ""
If ClickButton = True Then
WriteToLog "button found"
End If
Next
this will do wach one in the array
Re: moving to the next array?
VB Code:
ClickButton ""
If ClickButton = True Then
Either ClickButton is something that can hold a string or it's something that returns a boolean.
Are you referring to a button being clicked? Or is ClickButton a function that accepts a string parameter and returns a boolean (in which case, due to the way you use it, your executable is going to be overly complex)?
Re: moving to the next array?
Along Statics example, but using a Static variable.
Each subsiquant click of the button, increases the Array Index.
Beter yet, use a Form level (global) variable Dimmed (not Static) so you have the
ability to re-set it as required.
Pseudo:
VB Code:
Option Explicit
Dim varArray(0 To 1) As Variant
Dim intIdx As Integer
Private Sub Form_Load()
varArray(0) = "http://www.bbc.co.uk"
varArray(1) = "http://www.vbforum..com"
'more?
intIdx = 0
End Sub
Private Sub Command1_Click()
GoToPage (varArray(intIdx))
ClickButton ""
If ClickButton = True Then
WriteToLog "button found"
'Code.....
intIdx = intIdx + 1
End Sub
Private Sub cmdReset_Click()
intIdx = 0
End Sub