|
-
Mar 9th, 2002, 06:38 PM
#1
can you make your vb program retrieve stock quotes?
I want to make a program that will retrieve the stock quote of a company with a click of a button. Can you guys help me with the basic concept??
Where would the program be able to pull this information from?
-
Mar 9th, 2002, 06:56 PM
#2
What you could do is find a site that gives free quotes, then use the Inet Control to connect to that URL and get the source from the page. Then its just a matter of parsing the data that you get back to find what you want.
I would recommend running a quote, and copy the format of the URL, so you know what the format of the URL will be. Then, do a View Source on the page, so you can code where to look more easily.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Mar 9th, 2002, 07:08 PM
#3
Frenzied Member
This needs six text boxes and a command button (GetRates).
I used this to get exchange rates in a program i wrote:
This should go in the General Declarations:
VB Code:
Dim rateval(1 To 6) As String
Private Declare Function URLDownloadToFile Lib "urlmon" Alias _
"URLDownloadToFileA" (ByVal pCaller As Long, _
ByVal szURL As String, _
ByVal szFileName As String, _
ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long
Public Function DownloadFile(URL As String, _
LocalFilename As String) As Boolean
Dim lngRetVal As Long
lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0)
If lngRetVal = 0 Then DownloadFile = True
End Function
VB Code:
Private Sub Form_Load()
MsgBox DownloadFile("The location of thepage with the rates", "where to put file")
Dim CharFromFile As String * 100
ratename(1) = "USD/GBP"
ratename(2) = "CAD/GBP"
ratename(3) = "EUR/GBP"
ratename(4) = "FRF/GBP"
ratename(5) = "DEM/GBP"
ratename(6) = "JPY/GBP"
FilePos = 1
ratenum = 1
Open "table.txt" For Random As #1 Len = Len(CharFromFile)
Do
Get #1, FilePos, CharFromFile
PageString = PageString + CharFromFile
FilePos = FilePos + 1
Loop Until EOF(1)
Close #1
Do
TextPos1 = InStr(1, PageString, ratename(ratenum), 1)
TextPos2 = InStr(TextPos1, PageString, "class=", 1)
TextPos3 = InStr(TextPos2, PageString, "</a> ", 1)
LenOfNo = TextPos3 - (TextPos2 + 13)
rateval(ratenum) = Mid(PageString, TextPos2 + 13, LenOfNo)
ratenum = ratenum + 1
Loop Until ratenum = 7
End Sub
Private Sub GetRates_Click()
ShowText1.Text = rateval(1)
ShowText2.Text = rateval(2)
ShowText3.Text = rateval(3)
ShowText4.Text = rateval(4)
ShowText5.Text = rateval(5)
ShowText6.Text = rateval(6)
End Sub
kill "location of the downloaded file" 'deletes the file
-
Mar 10th, 2002, 10:10 AM
#4
the problem with pulling it from some website (which is the way i had it before) is that if i do it too often, will they find out?
im talking about collecting prices for all the companies in the market. So thats over 1000 quotes alredy in one shot..
maybe i should collect it in time intervals??
-
Mar 10th, 2002, 10:13 AM
#5
No matter what the interval, if you are going to hit a server over 1000 times each time, they will be pissed. I would recommend signing up for a service that provides software of their own.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
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
|