|
-
Jun 5th, 2004, 02:05 AM
#1
Thread Starter
New Member
Stupid string problem I CANNOT figure out!
Here's my program so far.
Code:
Private Sub cmdGet_Data_Click()
Dim Inet_Data As String
Dim Digit As String
Dim str As String
Dim Index As Integer
Dim x As Integer
Dim y As Integer
Dim Length As Integer
Inet_Data = Inet1.OpenURL("http://finance.yahoo.com/q/ae?s=" & tbTicker.Text)
'Find the price
x = InStr(Inet_Data, "Script")
tbOutput.Text = Mid(Inet_Data, x, 6)
End Sub
I'm just trying to pull data off yahoo's stock pages. I know Inet_Data has data, and I know it contains "Script". If the line
Code:
x = InStr(Inet_Data, "Script")
is run as is, it doesn't return anything to the x variable. if I change it so it's not case sensitive, ie.
Code:
x = InStr(Inet_Data, "Script",1)
I get a "type mismatch" error. If I try to put in a starting position, ie.
Code:
x = InStr(0,Inet_Data, "Script")
I get an "invalid procedure call or argument" error. So basically, instr doesn't work for me at all.
Please help!
-
Jun 5th, 2004, 02:22 AM
#2
There's nothing wrong with the way you're using InStr, except that if you specify a starting position it must be greater than zero.
If Inet_Data does contain 'script', then this line:
tbOutput.Text = Mid(Inet_Data, x, 6)
will only return the word 'script'.
ie. If Inet_Data = "abcdefghijkScriptlmnopqrst", then
InStr(Inet_Data, "Script") will equal 12, therefore
Mid$(Inet_Data, 12, 6) will equal 'Script"
Are you 100% sure there is data in Inet_Data and that it contains the text 'Script'? I can't really see anything wrong other than what I've mentioned.
Pete
No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.
-
Jun 5th, 2004, 05:04 AM
#3
PowerPoster
Hi,
Just a thought.
In
'Find the price
x = InStr(Inet_Data, "Script")
tbOutput.Text = Mid(Inet_Data, x, 6)
What are you trying to do? Unless this is an error tracing section to enable you to find out what is in the string at x (which won't work if the letters "Script" are not there) tbOutput.Text can never be anything else than "Script" or nothing.
It looks as if you are expecting "Script" to be a price!!!!
Is it possible that you mean the price is recorded in Script notation? (If that is the correct word).
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Jun 5th, 2004, 09:50 AM
#4
Thread Starter
New Member
Yeah, it was going to be price info eventually, but then I was running into problems, so I simplified it for now to figure things out.
I seem to have the code working for now, I reverted to an older save of the program, and took note of pnish's note that starting position must be greater than zero. Suddenly it worked with no other changes. Weird. Must have been some weird windows bug.
Thanks for the help though
-
Jun 5th, 2004, 10:56 AM
#5
The picture isn't missing
Originally posted by Kingstudly
Yeah, it was going to be price info eventually, but then I was running into problems, so I simplified it for now to figure things out.
I seem to have the code working for now, I reverted to an older save of the program, and took note of pnish's note that starting position must be greater than zero. Suddenly it worked with no other changes. Weird. Must have been some weird windows bug.
Thanks for the help though
Don't blame it on Windows. It was clearly your own fault .
Remember, if someone's post was not helpful, you can always rate their post negatively  .
-
Jun 5th, 2004, 01:41 PM
#6
Fanatic Member
But blaming it on windows makes everything so much easier!
-
Jun 5th, 2004, 02:25 PM
#7
Thread Starter
New Member
Yeah, I love it when I exit visual basic and the code doesn't work, then when I start it again later it does work...
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
|