PDA

View Full Version : importing delimited in VB, ACCESS or EXCEL


masterpeg
10-24-2004, 06:01 PM
I have started learning VB and am not sure where I want to create my program yet (access or VB), I am leaning toward VB because of the flexibility. I haven't gotten too far into VB yet, but am feeling better and better about it as I go along.

I haven't begun sketching a design yet for my program because I'm waiting to learn more and get more ideas of the possiblilities, but I keep thinking of this one problem I encounter while importing my DRF delimited files into access and excel and wonder if there is away to avoid it in VB.

The problem is , I would want the program to be able to handicapp one race at a time, and to use selected running lines. Whenever I import I end up with all of the running lines for all the races without any visible option to discriminate. Can someone give me a little insight as to if this is possible in any of these programs.

sjk
10-24-2004, 06:50 PM
It is easy to select lines based on your chosen criterion using Access. That is what queries are all about. I have never run up against anything I was unable to do with Access.

You could probably say the same for VB although I have never used it so I cannot help you with that.

Excel is good for many things but it does not have the versatility of a database program and I would consider it a poor choice.

Anything you use is going to require some time to learn and experiment with.

masterpeg
10-24-2004, 07:04 PM
are you saying you can choose which lines to import, or are you saying you import all lines first then select?

sjk
10-24-2004, 07:05 PM
Import first then select.

masterpeg
10-24-2004, 07:23 PM
I don't want to do it that way though. I wan't to be able to select which ones to import. Can that be done with Access or VB?

I think it will pose many problems in coding the formulas if I can't select first.

If anyone here uses VB and knows please let me know so I can plan my design accordingly.

osophy_junkie
10-24-2004, 11:57 PM
Your importing, selecting, and testing should all be different components. Having one big glob of code that does it all will decrease the amount of flexibilty available to you in the future.

Ed

Jeff P
10-25-2004, 12:24 AM
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:

Public 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

End If

Close #1


End Sub


Now, after enter clicking your command button and entering the name of a data file, here's what happens:

The file is opened. Each field is read from the file. The field value from the file is stored in the array. When each group of 1435 fields from the file have been read you are done with a single horse. It is at this point (at the comment that says 'Done With Single Horse, now do something interesting.) where you can begin picking the horse's past performance record apart.

I used 1435 fields for my example because I use Bris files which have 1435 fields per horse. Each array element corresponds to a field in the Bris Data File. For example, the horse's name can be found by looking at the value stored in FieldVal(45) which corresponds to field number 45 in the Bris File.

You can get a field map for Bris DRF Single Format Data files at:

http://www.brisnet.com/cgi-bin/static.cgi?page=drfsff

The same file reading strategy works with other file formats. You just need to know the number of fields in the file and what each one is supposed to contain.

masterpeg
10-25-2004, 01:44 AM
That was a lot of information Jeff. I'm not sure if Im ready for it yet, but I will copy it and store if for when I am. It is very much appreciated. What you have managed to do is answer my question and keep my interest high so I now have the fortitude to continue with this interest.

Since you are handy with VB, I will ask you a couple questions. I have just started learning and been watching a tutiorial video I got from learnkey. I also have an older V5 book to look at from the library and one on the way for V6 from Amazon.com. So far I am becoming familiar with controls and some bits of code "variables, and conditions." I haven't look ahead too much but found myself thinking, "I wish I had a VB dictionary."

Am I thinking the wrong way here? Should I expect to just follow the step by step guides to the end and somehow attain enough knowledge to create what I need or is there an all in one resource guide to find quick answers to code questions. The reason I ask is because while searching the net for all things VB I found a lot of available source code for the taking (all of which means nothing to me yet) with various titles (which I don't understand yet) designed to do things I can't comprehend yet, but may need at sometime.

How will I ever know what they do and if I could use them? Should I just forget about them and learn what I can expecting to write all my own code for my project? do programmers often use others' code (isn't there some copywrite infringements)?

BTW, back to the original question and your solution. Remember, I'm a newbie here.....but, when you import your files, do you use "excel" worksheet in VB to present the data, or did you create text boxes? or some other way. No details needed, just a general answer so I know where Im heading here. Thanks for all your input.

Jeff P
10-25-2004, 03:20 AM
Should I just forget about them and learn what I can expecting to write all my own code for my project?

For me it was a case of learning by doing. It's probably best to gain some understanding of VB programming techniques before attempting to tackle a handicapping app in VB.

I'd recommend getting your hands on some of the books by Microsoft Press. There's one called Visual Basic Step by Step that provides some very clear and thorough examples of what you can do with VB. Working through the examples can provide you a pretty solid foundation. If that seems a little over your head, get the Learning Edition of VB (check E-Bay.) It's written for beginners and comes with a book by Michael Halverson that's pretty good. That's how I got my start back in the day.


...but, when you import your files, do you use "excel" worksheet in VB to present the data, or did you create text boxes? or some other way.

I used VB to generate an HTML Report to present the data. I use this report for my handicapping on a daily basis. I also used VB to write a routine that merges the Bris data files with results files which then stores selected fields in a SQL table for later analysis. I then used VB to write a comprehensive analysis tool that lets me run queries against my database to see what factors are working (or not working) at specific tracks, distances, and surfaces. Then... I used VB to write a marker program that compares the past performance record of every horse in a Bris data file against my own wagering models. When this program finds a play that fits my own pre-defined criteria it "marks" the horse in such a way that the horse becomes highlighted on my HTML Report.

This last one is probably the most important part of my overall process. I no longer really have to handicap. All I have to do is look at my HTML Report each day to see those horses marked in red. Those are my potential plays for the day.

Light
10-25-2004, 11:14 AM
Hi Jeff P

I was wondering if you ever came up with code to retrieve horse racing html files results and put them into access or excel with a particular purpose in mind. I remember asking you about trying to automate making variants a particular way.You said you were working on it. Don't know if you ever came up with anything,but if you have anything related that works with HTML horseracing results,(that you care to share),I would appreciate it. Thanks for your generosity.

Jeff P
10-25-2004, 11:15 AM
One small correction to the code snippet I posted above:

In the declarations section, use:
Dim FieldVal(1435)

Instead of:
Public FieldVal(1435)

Jeff P
10-25-2004, 11:31 AM
Light,

My apologies.

Was working on it sporadically and got sidetracked.

Shoot me an email.

Larry Hamilton
10-25-2004, 11:47 AM
Jeff,
There is a similarity to my own code in what you do, though slightly different. You don't mention the "unzip" necessity, nor the need to include in your loop,"DIR", to capture all the files in your target folder. You saving those for a rainy day?

Jeff P
10-25-2004, 01:27 PM
Larry,

I have tons of code that fires before the code snippet that I provided.

I created a separate module to clear and load individual race cards. To read files from different folders, I use a dual strategy. First I have a Drive ListBox, a Folder ListBox, and a File ListBox sitting on a form. Code behind the change event procedure for the drive listbox resets the folder and file listboxes. Code behind the folder listbox resets the file listbox. This interface very closely mimics the interface used by Microsoft in Windows Explorer. This combination of listboxes allows user navigation to any folder on my system. Code behind the double click event procedure for the file listbox will load a race card any time a user double clicks on the file name.

The second part of my file loading strategy involves instantiating Microsoft's File System Object (FSO.) I use this to populate an array that always contains the file names with a match for the extension characters ".drf" (these are the extension characters that all bris files of the type I use have) that are sitting in the currently selected folder. The module has buttons with code behind them that allow a user to either: 1. Clear all loaded race cards and: 2. Find and load all race cards for a specific date.

As for unzipping, I've been using a combination of Windows Explorer and WinZip.

Currently, I'm working on writing my own unzip file utility into the above module. My strategy here is to use the free Info Zip library (Unzip32.dll - this is the same library used by WinZip even though they aren't the ones who developed it.) and have my own program act as a "wrapper" so that I can call some of the methods contained in the library to unzip files.

Larry Hamilton
10-25-2004, 04:49 PM
Sorry Jeff, I was trying to be funny and I didn't pull it off

Jeff P
10-25-2004, 05:47 PM
Larry,

It's not you.

More likely it's the mood I'm in.

One of my brainchild programs, which parses scratches and then processes them automatically, cleverly helped me and one or two others miss a $24.60 winner today at Delaware.

On top of that, now I have a coffe mug and an old softball trophy whose shattered remnants are keeping each other company in my garbage...

exactaplayer
10-27-2004, 12:03 PM
Hello,
I am trying to learn how to download data for todays races. I only want to look at two things. The horses starts and amount won for the year and the horses starts/w/p/s for todays distance. Can I get this information somewhere without having to pay a lot of money?
Exactaplayer

Pace Cap'n
10-27-2004, 06:25 PM
Originally posted by exactaplayer
Hello,
I am trying to learn how to download data for todays races. I only want to look at two things. The horses starts and amount won for the year and the horses starts/w/p/s for todays distance. Can I get this information somewhere without having to pay a lot of money?
Exactaplayer

Fifty-cents per track here:

www.tsnhorse.com/

You would need to download a free PP generator program, then download the comma-delimited files to the program.

exactaplayer
10-27-2004, 06:34 PM
Thank you
comma deliminated means I can put the data in an excell file right?
I'm going to look at link.

masterpeg
10-27-2004, 08:10 PM
Jeff...

I just took a look at Brisnet DRF files. Couple questions. Why do you use them over DRF's formulator files? and what is the differnce between single files and multi files? I downloaded a sample single file and looked at it in access, but it had no headings and don't wan't to spend too much time at this time researching it.

Jeff P
10-27-2004, 09:45 PM
I started using Bris back in 96. At that time I wanted a way to automate my handicapping process and eliminate much of the guesswork I was doing. Using the form, I found that I wasn't consistent in the way I'd arrive at my picks (and bets) from one day to the next.

I was pleasantly surprised to discover that the Bris figures had a fair degree of accuracy and even offered some value becasue not many people were using them compared to the numbers printed in the form.

At that time it was possible to win at the track I was playing (Turf Paradise) simply by identifying the top Bris speed figure in the race and then betting it to win whenever the odds on the horse were 6-1 or higher. Over the years the game has changed and simplistic methods like that no longer work. I believe that there has been a marked proliferation of players downoading data and using some type of software as part of their handicapping. If you want to stay ahead of the curve you've got to constantly be evolving as everything else around you changes too. For me, going to Bris and developing my own programs was key.

Very early on I looked at TSN files. In 97 or 98 I ran a handful of studies comparing the win rate and roi for my own methods based on Bris Data vs TSN Data. TSN data, for whatever reason, provided lower win rates and roi for my own methods. So over the years I've stuck with Bris.

Databases like Access have a limit of 255 fields for a single table. The Bris single format data file has 1435 fields in it. So it won't fit nicely into a single Access table. Multi file format means that the information for the same track and race date is broken out into individual files containing 255 fields or less so that each file can be loaded into a table without going over the limit for the number of fields. Sinlge file format doesn't care how many fields can exist in a table. For me, it's easier to use these. My own programs load the file, pick it apart, perform number crunching, and save any data that I want to keep in tables of my own design.

Hope that helps.

ranchwest
10-28-2004, 12:17 AM
Originally posted by masterpeg
That was a lot of information Jeff. I'm not sure if Im ready for it yet, but I will copy it and store if for when I am. It is very much appreciated. What you have managed to do is answer my question and keep my interest high so I now have the fortitude to continue with this interest.

Since you are handy with VB, I will ask you a couple questions. I have just started learning and been watching a tutiorial video I got from learnkey. I also have an older V5 book to look at from the library and one on the way for V6 from Amazon.com. So far I am becoming familiar with controls and some bits of code "variables, and conditions." I haven't look ahead too much but found myself thinking, "I wish I had a VB dictionary."

Am I thinking the wrong way here? Should I expect to just follow the step by step guides to the end and somehow attain enough knowledge to create what I need or is there an all in one resource guide to find quick answers to code questions. The reason I ask is because while searching the net for all things VB I found a lot of available source code for the taking (all of which means nothing to me yet) with various titles (which I don't understand yet) designed to do things I can't comprehend yet, but may need at sometime.

How will I ever know what they do and if I could use them? Should I just forget about them and learn what I can expecting to write all my own code for my project? do programmers often use others' code (isn't there some copywrite infringements)?

BTW, back to the original question and your solution. Remember, I'm a newbie here.....but, when you import your files, do you use "excel" worksheet in VB to present the data, or did you create text boxes? or some other way. No details needed, just a general answer so I know where Im heading here. Thanks for all your input.

IMHO, the best way to get started is one step at a time.

You might as well resign yourself to the fact that your first program will be relatively useless for handicapping. It will be your learning tool.

Learn to design the screen, read in a file(s), display some of the file contents, manipulate some of the data, etc. Conquer it all one step at a time. Sit back and admire your work briefly at the end of each step.

Once you get to the point where you feel like thumping your chest but you still don't have much that's really useful, you're probably ready to start over and make a real attempt at writing a useful program.

On about the 400th iteration of writing a program, go to the refrigerator, get out a beer and figure up how much time you wasted. lol

Seriously, you'll learn a lot about what does and doesn't work, both in programming and in handicapping.

masterpeg
10-29-2004, 08:37 PM
I understand...

fact is, I am going to be spending a lot of time writing programs unrelated to handicapping before even attempting my end goal. I will work through three books and 18 hour video learning all I can and gaining ideas along the way.

I am aware designing is the most important part and am taking my time and jotting down ideas as I go. I am realistic and my deadline is "whenever". I just hope horseracing doesn't go away before I finish. That is the only way this would be a waste of time.

thelyingthief
11-05-2004, 09:18 AM
For Larry Hamilton and Jeff P:

I'm currently working on VBA, with an immediate eye to automating import of files into Access. Any ideas you have on this would be appreciated. As youre no doubt aware, learning to do ONE thing in a language, often means learning to do A LOT in it, too. Also, if you can give me a reference or source that will help me write a script to automate my data download, I would greatly appreciate the help.

For you guys learning VB:

Let me recommend one book that's really good: VisualBasic.Net, How to Program, 2nd Ed., by Deitel and Deitel. It's 1500 pages or so of extremely in depth introduction not only to VB (as the name implies), but Microsoft's current IDE for developing programs in it. But the really good thing about the book is its handling of the strategies and tactics of programming itself. I used Deitel and Deitel to learn C++ (these two have a number of books about the various languages, including java, c++, c#, and vb), and the number of exercises and coverage of both the structural approach to programming, and object oriented thinking, sticks with you through everything you do elsewhere. I cant recommend them enough. By the way, the elder Deitel teaches programming at MIT, or did; so you're getting the best from the best. I will warn you that the books ain't cheap, the vb book costs 87 dollars. You can obtain it from Amazon through one of their independent sellers for around $40. Also, you will need to get Visual Studio, but Academic Versions are obtainable from Ebay for under 75--not an overwhelmingly expensive solution. Oh, and, you probably should prepare to be intimidated, too. The exercises are NOT trivial: you develop solutions for things like the knight's tour and the towers of hanoi. These books are used at many of the best institutions in the land.

Larry Hamilton
11-05-2004, 09:51 AM
What you ask is the first problem I had to solve years ago. One of the guys who helped me first was our own Mike (PA). My total solution over the years consists of:

1) a program that downloads the proper files for the proper day. I purchased this stand alone product from one of the members of this board. He will respond to you if he is still doing it.

2) a program (macro module) that unzips the download (using WinZip)

3) a program (macro module) that reads the delimited files--free--Infotran

4) a program (macro Module) that uploads the delimited files to a table in access.

where would you like to start?

thelyingthief
11-05-2004, 12:00 PM
Larry: you tell me.

on topic 1, purchasing seems expedient, but problematic. For instance, I obtained GameTheory's charts download and parsing application sometime ago; now GT informs me he will not support the program shoud Equibase change their data format, or etc. Given the scope of the project I intend, downloading and filing simply MUST be automated; so what will I do when they DO change? Which appears to be the same issue I must confront with my PP downloads, too--so, I'm pretty much coerced to develop my own mechanism for each procedure. I'm very much in the way of a man that's hungry, but would rather have a fishhook than a fish.

on topic 2 & 3, I use the DRF files, and depend on the formulator series to unzip, read and translate those into delimited files. I assume that I can write a VBScript that will open that program (I have experimented with that, and found that I can), choose the export function, and the files, and process them to a folder for further use (I have not experimented with these, this step in the automation is the least apt to produce db contamination, and takes the least time to do). Can you tell me if this is even possible using a script? I'm not comfortable enough with the windows environment to know what limitations are placed on manipulating third party software. Do you know if I can use Infotran to perform these functions? After all, zip functions are pretty simple, and the Formulator may have its own procedures for encoding and decoding their files.

on topic 4, this is the most immediate of my problems. DRF file conversion returns a file name with an extension unrecognized by windows. I have written a script that processes these files by extracting the native extension and the basename, concatenating the two, and adding the suffix .txt, then relocating the renamed file in another folder. Now I am confronted with several problems. One being: should I write a script that tackles the problem from without, using WSH, or use VBA to import those files from within the DB? The next being: exactly what will the impact of the DRF file structure have upon my procedure? They use multiple files to aggregate all the data that appears on the race form. Generically, the file names look like this: "dateTrackAbreviationRacenumber.ch(chr,chs, cht, chv, pgh)". I rename those files, as stated, deleting the dot, and adding the suffix .txt. So, I use base tables named "Trkch, Trchr", etc.. So I will have to loop through the file folder and import each file to its proper target. And since I currently keep several db's, segregated by circuit, into the appropriate db as well. This last caveat has me thinking I should tackle it from without using a script, but at this point in the game I just don't know what IS or IS NOT possible.

Thanks for any help,
TLT

Larry Hamilton
11-05-2004, 12:24 PM
1) I see that you have been forced by circumstances to find the best solution, which is write the code yourself that does the downloading automatically. I will admit I have not conquered this yet, mostly because I am not capable of writing better code than that I bought.

2,3) This is a problem for which I have no answer. If you had BRIS either multi or single downloads, or trackmaster or TSN I could fix that because I have already done that at one time or another. I know two things about Formulator product that will cause me to probably never buy them. They cost more than what is available elsewhere and they provide PERISHABLE backup data.

You ask can VB be used to run other Non MS software--yes.

I have an older edition of VB (V5). It requires turning other programs into objects to run them. My son in law helped me a great deal with this. It is a routine in visual basic that opens and runs a program in Excel. Will it work with other programs..dont know, never tried other than Access.

Public Sub ExcelApp(WorkbookName As String, ProcName As String)
On Error Resume Next
Set objExcel = GetObject(, "Excel.Application")
If objExcel Is Nothing Then
Set objExcel = CreateObject("Excel.Application")
End If
On Error GoTo ErrHandler
objExcel.Visible = False
If WorkbookName <> "" Then
objExcel.Workbooks.Open WorkbookName
If ProcName <> "" Then
objExcel.Run ProcName ',Param1,...
End If
End If
ErrHandler:
If Err Then
MsgBox Err.Source & " Error # " & Err.Number & vbCrLf & Err.Description
End If
End Sub

4. I did the same thing. I changed the ext with code. .BAS will flip flop with .txt easily. But then you are faced with several problems. The input is larger in fields, than your program is capable of accepting. The solution I chose was to make many inputs all connected by relating Date, Track, RaceNumber and Program Number.

Hope that helped.

Also, I can be far more help if we are talking about TSN or BRIS.

edek
11-05-2004, 04:32 PM
Trying to automate formulator with a vb script (or a vb application) may be a problem.
Unless an application has the ability to export it's "object model", you won't be able to access it's parts like you can with an MS app like excel/access.

thelyingthief
11-05-2004, 04:56 PM
then again I may: since all programs that use the xp OS must register in the environment, I should be able to gain access to all its registered components (i.e. the parser) and issue directives to its stacks and executables. On the other hand I may not, as you say.


that's my issue in a nutshell--I can't get a concrete response yea or nay from someone who KNOWS...

(and thanks for your input, Larry)

TLT

edek
11-05-2004, 06:39 PM
Hey thief,
Unless those executables "expose" methods (probably through a DLL) I don't think you would be able to directly call the export feature. I am only familiar with the free example .dr2 file. If that is the way it works (a password encrypted file), DRF is going out of their way to prevent database building.

Any reason why you use the DRF PP. Other then having a the Beyers in your database (which granted, I would like to have), for database building purposes, any of the more "open" data files might be better (also cheaper).

Ed

Tim
11-05-2004, 08:22 PM
TLT,

I also use the DRF Formulator CSV extracts. I wouldn’t waste any time trying to write a custom extract program. IMHO it's easier to use the Formulator’s “Export DRF Race Card” function. The extract procedure supports extracting around 50 race cards at a time. (At some point above that there seems to be a buffer or variable size limitation)

As for loading the data into Access, why are you bothering with VB, Why not write the import procedure in Access.

What version of Access are you using?

Tim

thelyingthief
11-05-2004, 10:47 PM
tim:

access 2002. automated procedures for reading the files have to be done in vba, don't they? i dont know a lot about macro building, but to my understanding, they won't let me do the kind of looping through many files and assigning them to their proper db. is this correct?

also, im lucky to get five or six cards simultaneously exported using formulator.

sjk
11-06-2004, 07:51 AM
TLT,

I don't know any way to change the names of files imported by a macro in Access. If renaming the files is part of the process anyway you could use a fixed set of names: T1, T2, ... for your files and set up the macro to import files of those names. You might need to have different macros according to the number of files you need to import.

Tim
11-06-2004, 11:09 AM
TLT,

A Guess with your DRF Extract limitations: Are you leaving the folder names (either the dates or tracks) selected when trying to export a group of race cards? Do you have at least 256Meg of memory?

Macros: Don’t use them, they are more trouble than they are worth. It’s just as easy to learn how to write code as it is to learn how to write macros.

If you want, I can email you a small (760K) MDB that is set up to import Formulator CSV extracts. Then you can see how it works.

Tim

sjk
11-06-2004, 06:45 PM
Alternate point of view on Access macros:

I can't imagine anything could be as easy to learn. I have found them to be capable of whatever I needed them to do.

thelyingthief
11-08-2004, 11:59 AM
Tim:

Is the coding visible in the mdb? Can I view the module through my VBA IDE? If so, by all means. You can leave me a private message, and I will respond so that you'll have my email address.

Sjk.

I wrote a VBScript that renames the files and moves them to a folder I use as a depository for Import. If you have a macro that will move a file into its proper target, I would like to see it. I can edit my script to sequester files of a specific type (by TrackName, etc.), and use your macro. Could you recommend a book that will instruct me on designing macros?

To both:

I don't know if either of you use DRF files, but they parse into 7 seperate files which I import into tables named after each of the files. From these tables I construct a db that is normalized and keyed. So, whatever method I use to automate import, I would like to continue this strategy if possible.

TLT

thelyingthief
11-08-2004, 12:07 PM
Tim:

I forgot to respond to your questions. I have a gig of ram, and no, I dont leave the folder selected. I think part of the problem has been my export to subfolders I added to the export folder path created by formulator. After writing my script I now export everything into Export and from thence into an Import folder, and I can export more files than before. It also seems that I have to select multiple files in a certain order, especially if exporting more than one track name, as I do.

TLT

Marc At DRF
11-08-2004, 05:18 PM
We're looking at Formulator 4.1 enhancements right now, plausibly for a Spring '05 release. One item on the list is making our export files easier to work with, or in any other way improving them.

If you have any improvements in mind, please drop me a note at mattenb@drf.com, and I'll see what we can do to make it easier for you guys to work with these files.

rrbauer
11-19-2004, 03:37 AM
Marc @ DRF wrote:
If you have any improvements in mind, please drop me a note at mattenb@drf.com, and I'll see what we can do to make it easier for you guys to work with these files.

Comment:
One request, Marc: If it works, don't fix it!

Marc At DRF
11-19-2004, 10:43 AM
two comments in response:

1) There were some issues with our export files pointed out here, and we did just fix them, I believe. Thanks for the heads-up.

2) We can't leave well enough alone. In a conference call yesterday to discuss Formulator 4.1 it was agreed the top priority was making the export files easier to use, easier than anything out there. We'll see if we deliver but that's the idea.

rrbauer
11-20-2004, 11:14 AM
Marc @ DRF wrote:

In a conference call yesterday to discuss Formulator 4.1 it was agreed the top priority was making the export files easier to use, easier than anything out there. We'll see if we deliver but that's the idea.

Question: How many customers participated in the conference call?

Marc At DRF
11-22-2004, 11:32 AM
Richard,

Zero customers participated in the conference call.

Instead, I continue to consult with a team of beta-testers to ask them how we can improve this product, and I forward these suggestions to our development team. Without the contributions of these testers, it would be difficult to understand how to better Formulator.

Tom
11-22-2004, 08:48 PM
Wonder if these beta testers also suggested removing the staples for Sim Weekly, so that it fall apart easily. That was a huge improvement in the product.:rolleyes:

Thomason
12-06-2004, 07:49 PM
Jeff P,

On October 25, you made several posts about VB code, including one about using VB to read a past performance file. The snippet you provided worked great. In a subsequent post, you said:

"I used VB to generate an HTML Report to present the data. I use this report for my handicapping on a daily basis."

How do you do that?

Jeff P
12-06-2004, 08:58 PM
Thomason,

I'm going out with some friends for a few hours.

I'll post some code samples sometime before this time tomorrow.

Jeff P
12-07-2004, 02:00 PM
Thomason,

In my original post I offered the following code sample for openeing a past performance file using VB or VBA in Access:



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




Yesterday, you asked me how I would go about sending output
from the opened file to an html report.

HTML offers a great deal of power and flexibility for formatting
output. I greatly prefer it over using the Access Report Engine for
many many reasons. One of those reasons is that HTML is
portable. It's very easy to post a link to an html report on a
webpage. An html report sitting on a client machine folder will
open and display in a user's web browser whenever the user
gives the file a double click, etc. On top of that, once you
understand html and/or the DOM, you gain complete control over
the appearance of every element found in the document, etc.

I'm getting sidetracked here. My goal here isn't to tout HTML over
the Access Report Engine. Both are what they are.

Using VB or VBA, you can write every part of an html document to
an HTML file. This includes all tags, including meta tags,
style tags, script tags, head tag, body tag, as well as the more
common html tags for tables, paragraphs, break tags, etc.


One way to embed an HTML report into the above code snippet
would be to do something like this:

1. Create a Sub like the one below:


Private Sub WriteHTMLReport(FieldVal)

Open "HTMLReport.html" for Output as #2

'``````````````````````````````````````````
'Write title, style, script, html, and body tags
'``````````````````````````````````````````
strHorseHTML = "<html><head><title>JCapper HTML Report1</title>"

strHorseHTML = strHorseHTML & "<STYLE>" & vbCrLf & "<!--" & vbCrLf
strHorseHTML = strHorseHTML & vbCrLf
strHorseHTML = strHorseHTML & ".Content" & vbCrLf & "{" & vbCrLf & "FONT-WEIGHT: normal;" & vbCrLf & "FONT-SIZE: 11px;" & vbCrLf & "Font-FAMILY: Sans-Serif , Verdana , Arial" & vbCrLf & "}" & vbCrLf

strHorseHTML = strHorseHTML & ".ContentGray" & vbCrLf & "{" & vbCrLf & "FONT-WEIGHT: normal;" & vbCrLf & "FONT-SIZE: 11px;" & vbCrLf & "Color: gray;" & "Font-FAMILY: Verdana , Arial" & vbCrLf & "}" & vbCrLf
strHorseHTML = strHorseHTML & " -->" & vbCrLf & "</style>" & vbCrLf

'``````````````````````````````````````````
'script tag
'``````````````````````````````````````````
strHorseHTML = strHorseHTML & "<script language=" & """" & "javascript" & """" & ">" & vbCrLf
strHorseHTML = strHorseHTML & "<!--" & vbCrLf

'``````````````````````````````````````````
'JavaScript functions
'``````````````````````````````````````````
strHorseHTML = strHorseHTML & vbCrLf & vbCrLf

'displayInfoPassedIn
strHorseHTML = strHorseHTML & "function displayInfoPassedIn(sInfo)" & vbCrLf
strHorseHTML = strHorseHTML & " // display the info passed in" & vbCrLf
strHorseHTML = strHorseHTML & " {" & vbCrLf
strHorseHTML = strHorseHTML & " alert(sInfo)" & vbCrLf
strHorseHTML = strHorseHTML & " }" & vbCrLf
strHorseHTML = strHorseHTML & vbCrLf & vbCrLf

'``````````````````````````````````````````
'close script tag
'``````````````````````````````````````````
strHorseHTML = strHorseHTML & "-->" & vbCrLf
strHorseHTML = strHorseHTML & "</script>" & vbCrLf


'``````````````````````````````````````````
'close out the head tag/write the body tag
'``````````````````````````````````````````
strHorseHTML = strHorseHTML & "</head><body>"
Print #2, strHorseHTML


'``````````````````````````````````````````
'Print Button
'``````````````````````````````````````````
strClickToPrint = " onClick=" & """" & "javacript:self.print(); " & """"
strStyleCursorHand = " style=" & """" & "cursor:hand" & """" & "; "
strHorseHTML = "<table style='border:1px ridge #9966ff; position:relative; left:10px; "
strHorseHTML = strHorseHTML & "top:0px;' bgcolor='#ffffee' >"
strHorseHTML = strHorseHTML & "<tr>"
strHorseHTML = strHorseHTML & "<td width='100%' class='ContentSmall' align='left' valign='top' " & strStyleCursorHand & strClickToPrint & " > "
strHorseHTML = strHorseHTML & "PRINT"
strHorseHTML = strHorseHTML & "</td></tr></table><br>"
Print #2, strHorseHTML


'``````````````````````````````````````````
'Display the horse name in a table
'``````````````````````````````````````````
strHorseHTML = strHorseHTML & "<table><tr><td>"
strHorseHTML = strHorseHTML & FieldVal(45)
strHorseHTML = strHorseHTML & "</td></tr></table><br>
Print #2, strHorseHTML



'``````````````````````````````````````````
'Close out the body and html tags
'``````````````````````````````````````````
strHorseHTML = strHorseHTML & "</body></html>"
Close #2


End Sub



2. Then, just under the comment in the original code snippet where it says:

"'Done With Single Horse, now do something interesting."

Simply place a Call to the above Sub, passing the array named
FieldVal that contains all of the horse data as an argument:

Call WriteHTMLReport(FieldVal)

You may have to play with it a bit to get the output you want. I
just did a cut and paste of pieces here and there from the HTML
Report I use in JCapper, but it does illustrate at least one
strategy for reading a past performance file to create an HTML Report as output.


Good Luck,


Jeff

Jeff P
12-07-2004, 02:19 PM
Thomason,

I'd like to amend my previous post just a tad...

You don't wan't to place the call to WriteHTMLReport(FieldVal) just after the comment. Otherwise you end up with an HTML Report for each horse.

DOH!

You are going to need to insert logic to determine the start and end of each race and use a multidimensional array variable so that it contains an index for each track and race number as well as each horse number.

Something like this in the Declarations section of your project:


'FieldVal (20 tracks, 250 races, 1500 horses, 1435 fields per horse)
Dim FieldVal(1 to 20, 1 to 250, 1 to 1500, 1 to 1435)


You want to place your call to WriteHTMLReport(FieldVal) after all races have been read from all loaded files.

Again Good Luck,


Jeff

Tom
12-23-2005, 10:09 PM
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:

Public 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

End If

Close #1


End Sub


Now, after enter clicking your command button and entering the name of a data file, here's what happens:

The file is opened. Each field is read from the file. The field value from the file is stored in the array. When each group of 1435 fields from the file have been read you are done with a single horse. It is at this point (at the comment that says 'Done With Single Horse, now do something interesting.) where you can begin picking the horse's past performance record apart.

I used 1435 fields for my example because I use Bris files which have 1435 fields per horse. Each array element corresponds to a field in the Bris Data File. For example, the horse's name can be found by looking at the value stored in FieldVal(45) which corresponds to field number 45 in the Bris File.

You can get a field map for Bris DRF Single Format Data files at:

http://www.brisnet.com/cgi-bin/static.cgi?page=drfsff

The same file reading strategy works with other file formats. You just need to know the number of fields in the file and what each one is supposed to contain.

Could this be used in VBScript to open data files and then select fields to use in calulations? Not really familiar with anyhting past DOS basic, but trying to learn VBScript.
Is VBS a form of Visual Basic?

Thanks,

Jeff P
12-24-2005, 12:39 AM
First, a little background...

What is VBScript?

VBScript is a stripped down offshoot of VB. It's designed primarily to be run on a server for the purpose of presenting web pages. A lot of the functionality present in VB, particularly functionality related to handling files, isn't supported in VBScript. There is a good reason for this. If VBScript were able to perform file handling (renaming, editing, deleting, etc) then whenever you'd browse to web page with embedded VBScript you'd run the risk of having that web page do something malicious to your own machine. Microsoft wanted to avoid that risk so they stripped file handling capability out of VBScript when they released it as part of Visual Studio. Sure, there are other ways for programmers to have web pages do nasty things to a client machine, but the capability to do so isn't built in to VBScript.

Okay, so on to your question:

Could this be used in VBScript to open data files and then select fields to use in calulations? Not really familiar with anyhting past DOS basic, but trying to learn VBScript. Is VBS a form of Visual Basic?

The OPEN and INPUT# statements aren't supported in VBScript. So no, the code block I presented won't work in VB Script as is.

Now, what you could do in VBScript is adopt a slighly different strategy for opening the file. You could register an object written in VB6 on the server. This object could have the ability to open and pick apart a data file. It could have public functions that return values back to the VBScript based web page where it is instantiated.

For example, suppose the VB6 object is named "FileReader" and registered on the server with a ProgID of "FileReader.ProgId." And suppose this object has a public function named getSpeedFigure() that returns a Speed Figure calculated from data pulled from a loaded data file.

A VBScript code snippet to present the speed figure on the web page might look something like this:

<%

Dim objFileReader
Dim intSpeedFigure

'Instantiate the FileReader object
Set objFileReader = "FileReader.ProgId"

'Get the Speed Figure
intSpeedFigure = objFileReader.getSpeedFigure()

'Release Object References
Set objFileReader = Nothing

%>

At this point the variable named intSpeedFigure holds the value of the speed figure returned by the getSpeedFigure() function and could be presented on the web page along with whatever other data you are presenting to the user.

-jp

.

Tom
12-24-2005, 10:49 AM
Thanks, Jeff, and Merry Christmas to you and yours.