Results 1 to 4 of 4

Thread: moving to the next array?

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2006
    Posts
    10

    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

  2. #2
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    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:
    1. For x = 0 to 1 ' or if u dont know how many are in your array
    2. 'For x = 0 to ubound(varArray)
    3. GoToPage (varArray(x))
    4.  
    5. ClickButton ""
    6. If ClickButton = True Then
    7. WriteToLog "button found"
    8. End If
    9. Next
    this will do wach one in the array
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: moving to the next array?

    VB Code:
    1. ClickButton ""
    2. 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)?
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  4. #4
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    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:
    1. Option Explicit
    2.  
    3. Dim varArray(0 To 1) As Variant
    4. Dim intIdx As Integer
    5.  
    6. Private Sub Form_Load()
    7.     varArray(0) = "http://www.bbc.co.uk"
    8.     varArray(1) = "http://www.vbforum..com"
    9.     'more?
    10.  
    11.     intIdx = 0
    12.  
    13. End Sub
    14.  
    15. Private Sub Command1_Click()
    16.  
    17.     GoToPage (varArray(intIdx))
    18.    
    19.     ClickButton ""
    20.     If ClickButton = True Then
    21.     WriteToLog "button found"
    22.     'Code.....
    23.  
    24.     intIdx = intIdx + 1
    25.  
    26. End Sub
    27.  
    28. Private Sub cmdReset_Click()
    29.     intIdx = 0
    30. End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width