|
-
Oct 19th, 2010, 01:29 AM
#1
Thread Starter
Member
[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.
-
Oct 19th, 2010, 01:36 AM
#2
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
-
Oct 19th, 2010, 01:48 AM
#3
Thread Starter
Member
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.
-
Oct 19th, 2010, 01:51 AM
#4
Thread Starter
Member
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
-
Oct 19th, 2010, 01:51 AM
#5
Re: InStr and Click question
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
-
Oct 27th, 2010, 11:54 PM
#6
Thread Starter
Member
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.
-
Oct 28th, 2010, 12:38 AM
#7
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.
-
Oct 28th, 2010, 10:43 PM
#8
Thread Starter
Member
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.
-
Oct 29th, 2010, 08:56 AM
#9
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|