Results 1 to 9 of 9

Thread: [RESOLVED] InStr and Click question

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2006
    Posts
    57

    Resolved [RESOLVED] InStr and Click question

    My code works! BUT... always a but. It selects the very first link im searching for on the page.. which is MY own. Mines always the top of the list, how do I make it skip and click the second ( or third or fourth for that matter) instance?

    I tried
    Code:
    holder = InStr(2, IExp.Document.all.Item(i).href, "player_id?=")
    But that didnt seem to work.

    any help would be awsome. thanks!.. here is a snippet.

    Code:
    For i = 0 To 2000 ' iexp.document.all.length
      
        holder = 0
    
        On Error Resume Next
        holder = InStr(IExp.Document.all.Item(i).href, "player_id?=")
        On Error GoTo 0
        If holder > 0 Then
    
          IExp.Document.all.Item(i).Click
          
          Do Until IExp.ReadyState = 4
        DoEvents
      Loop
      Sleep 4000
    looking for help to make it skip the first instance and click the 2second instead.

  2. #2
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: InStr and Click question

    One logic...

    You need to find the first instance and get's it position and then search again from that position onwards

    Sample:

    Code:
    Sub Sample()
        Dim StrSample As String
        Dim pos1 As Long, pos2 As Long
        
        StrSample = "This is an Example. This Example is blah blah"
        
        '~~> Objective: Need to get the Second word "Example"
        pos1 = InStr(1, StrSample, "Example")
        pos2 = InStr(pos1 + 1, StrSample, "Example")
        
        '~~> Gives you the position of the 2nd "Example"
        MsgBox pos2
    End Sub
    Last edited by Siddharth Rout; Oct 19th, 2010 at 01:40 AM.
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  3. #3

    Thread Starter
    Member
    Join Date
    Nov 2006
    Posts
    57

    Re: InStr and Click question

    I tell ya ... my profile says "You last visited: Jan 20th, 2009 at 08:37 AM "

    I show up here almost 2 years later for a little help and BAM!!!!!!! ... instant resolve!

    This place never lets me down its beyond amazing.

    Thank you Sir, and what? 4 min reply and solved.

  4. #4

    Thread Starter
    Member
    Join Date
    Nov 2006
    Posts
    57

    Re: InStr and Click question

    oh lol I just changed this.. I didnt even see you gave me a an example.. I just read your " LOGIC".. and thought a bit more about it. haha..

    Code:
    For i = 6 To 2000 'iexp.document.all.length
      
        holder = 0
        On Error Resume Next
        holder = InStr(6, IExp.Document.all.Item(i).href, "profile_id")
        On Error GoTo 0
        If holder > 0 Then
          IExp.Document.all.Item(i).Click
          
          Do Until IExp.ReadyState = 4
        DoEvents
      Loop
      Sleep 4000
    regardless same thing! thanks again

  5. #5
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: InStr and Click question

    Gr8

    I tell ya ... my profile says "You last visited: Jan 20th, 2009 at 08:37 AM "
    You need visit this site more often then

    Well, if your query is solved then do remember to mark the thread resolved Check the link in my signature on how to do it

    Take care

    Sid
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  6. #6

    Thread Starter
    Member
    Join Date
    Nov 2006
    Posts
    57

    Re: [RESOLVED] InStr and Click question

    I have a further question for the above..

    Ive used "click"...

    but now is there code to actually COPY the link?? and possibly paste it into excel, each link one after another as visited?

    Code:
    IExp.Document.all.Item(i).Click

    is there something out there like

    Code:
    IExp.Document.all.Item(i).COPY
    ????

    I have successfully done this with sendkeys... but I hate the cheapness of sendkeys.

  7. #7
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: [RESOLVED] InStr and Click question

    You don't need to post the same question in two places. Also, if a followup question is closely related to the original you can ask in the same thread.

  8. #8

    Thread Starter
    Member
    Join Date
    Nov 2006
    Posts
    57

    Re: [RESOLVED] InStr and Click question

    I asked this question... hoping the RESOLVED would disappear and it would be unresolved again.. but nope... so I made a new thread. Sorry.

  9. #9
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: [RESOLVED] InStr and Click question

    No problem. To unresolve a thread you need to edit your first post, then manually delete the [Resolved] tag from the thread title.

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