Horse Racing Forum - PaceAdvantage.Com - Horse Racing Message Board

Go Back   Horse Racing Forum - PaceAdvantage.Com - Horse Racing Message Board > Thoroughbred Horse Racing Discussion > General Handicapping Discussion


Reply
 
Thread Tools Rate Thread
Old 04-17-2005, 08:53 AM   #1
exactajack
Registered User
 
exactajack's Avatar
 
Join Date: Feb 2005
Posts: 31
vb code for looping

can any programmers out the share some code for how you loop thru the data files to get each horse name to display with it's race dates underneath it and then the next horse and so on
exactajack is offline   Reply With Quote Reply
Old 04-17-2005, 10:00 AM   #2
syyamo
Journeyman
 
Join Date: Aug 2001
Location: Central Florida
Posts: 43
The following is from another post on this topic somewhere on this board:

------------------------------------------------------------------------
Using VB to read a past performance file is not all that hard to do. Here's a code snippet that I've used with VB6 with great success for years.
Something very similar should work as VBA code inside of Access 97 or Access 2000.

Create a standard EXE VB project and add a command button to your form.

In the declarations portion of your VB Project, paste in the following code:

Dim FieldVal (1435)
Public FILE as String

And then place this bit of code in the click event procedure behind the command button:

FILE = InputBox("Enter File Name:")
If Not FILE = "" Then
call ReadAFile(FILE)
end if


And then create a subroutine named ReadAFile. Here's the code for that; you can just copy and paste it in:

Private Sub ReadAFile(FILE)

Err.Clear
On Error Goto handler:

Open FILE for input as #1

Do While Not EOF(1)

'Read A Single Horse:

For j = 1 To 1435
Input #1, fileField
FieldVal(j) = fileField
Next j


'Done With Single Horse, now do something interesting.




Loop


handler:
If Not Err.Number = 0 then

MsgBox Err.Number & " " & Err.Description, vbCritical, "Error"
Err.Clear
-------------------------------------------------------

Just pull out the horse name and date from the array and your done.
syyamo is offline   Reply With Quote Reply
Reply





Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

» Advertisement
» Current Polls
Wh deserves to be the favorite? (last 4 figures)
Powered by vBadvanced CMPS v3.2.3

All times are GMT -4. The time now is 12:37 PM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 1999 - 2023 -- PaceAdvantage.Com -- All Rights Reserved
We are a participant in the Amazon Services LLC Associates Program, an affiliate advertising program
designed to provide a means for us to earn fees by linking to Amazon.com and affiliated sites.