For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic Syntax > March 2006 > Problem with finding substring Instr









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Problem with finding substring Instr
Joe

2006-03-02, 7:03 pm

Hi, I use a variable to store the HTML text from a webpage.

I wanted to find a substring in the HTML text using Instr function

However, this doesn't work.

I use
foundPos0 = Instr(1, "tabledata", strHTML)

and it always return zero.

Is there something I am missing? Length limit on the text string?
substring in double quotations in strHTML?

Please help.


Rick Rothstein [MVP - Visual Basic]

2006-03-02, 7:03 pm

> Hi, I use a variable to store the HTML text from a webpage.
>
> I wanted to find a substring in the HTML text using Instr function
>
> However, this doesn't work.
>
> I use
> foundPos0 = Instr(1, "tabledata", strHTML)
>
> and it always return zero.
>
> Is there something I am missing? Length limit on the text string?
> substring in double quotations in strHTML?


I presume the text from the webpage is in the strHTML variable and the
"tabledata" is the text you want to find inside it? If so, you have your
arguments backwards...

foundPos0 = Instr(1, strHTML, "tabledata")

and

foundPos0 = Instr(1, strHTML, "tabledata", vbTextCompare)

if you want the search to be case insensitive.

Rick


Larry Serflaten

2006-03-02, 9:58 pm


"Joe" <johntyung@yahoo.com> wrote
> Hi, I use a variable to store the HTML text from a webpage.
>
> I wanted to find a substring in the HTML text using Instr function
>
> However, this doesn't work.
>
> I use
> foundPos0 = Instr(1, "tabledata", strHTML)
>
> and it always return zero.


Reverse the string parameters;

foundPos0 = Instr(1, strHTML, "tabledata")


LFS


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com