Front Office Football Central  

Go Back   Front Office Football Central > Archives > FOFC Archive
Register FAQ Members List Calendar Mark Forums Read Statistics

Reply
 
Thread Tools
Old 12-16-2006, 06:03 PM   #1
Oilers9911
College Benchwarmer
 
Join Date: Jan 2006
Ping: Visual Basic Programmers

I am trying to learn VB programming and my first project is a very simple soccer game based on attack and defence ratings. What I want to do is store the teams and their rating in a .dat file that can retrieve the ratings as each team plays. It is very simple. The only data I need to store is the team name (example, Liverpool) the nickname, (The Reds), home ground (Anfield), attack rating (an integer between 1 and 100) and defence rating (between 1 and 100).

What is the best way to do this? Just create a text document with something like Liverpool,The Reds,Anfield,78,76? Or do I have to create some kind of input form and write the data to a file that way?

Thanks guys.

Oilers9911 is offline   Reply With Quote
Old 12-16-2006, 06:26 PM   #2
Coder
College Prospect
 
Join Date: Nov 2000
Location: Gothenburg, Sweden
create a type for the team.. like this:

Code:
Type tTeam Name As String * 20 Stadium As String * 20 AttackRating As Byte DefenseRating As Byte End Type

The use random access to retrieve the data

lets see if I remember this.. might be a bit sloppy, but whatever

Code:
Dim AllTeams() as tTeam Dim tmpTeam as tTeam Dim TeamFile as string Dim TeamsRead as integer TeamFile = App.Path & "\TeamFile.dat" Open TeamFile For Random As #1 Len = Len(tmpTeam) Do While Not EOF(1) Get #1, TeamsRead, tmpTeam TeamsRead = TeamsRead + 1 ReDim Preserve AllTeams(TeamsRead) AllTeams(TeamsRead) = tmpTeam Loop Close #1

Oh.. and obviously you need to save as well.. check this article out:

http://support.microsoft.com/kb/150700

Since you have so few variables, you might actually use textfiles rather than binary files though..

That's much easier..

Use the same type, but start by creating a textfile like this:

Liverpool,Anfield,60,70
Arsenal, Emirate Stadium, 99,99

Then use this little sub to read rather than the stuff I used above (replace everything from Open to Loop

Code:
Dim arTeam() as String Dim TeamsRead as Integer Open FileName for Input as #1 Do while not eof(1) Line Input #1, s arTeam = Split(s,",") tmpTeam.Name = arTeam(0) tmpTeam.Stadium = arTeam(1) tmpTeam.Attack = CInt(arTeam(2)) tmpTeam.Defense = CInt(arTeam(3)) TeamsRead = TeamsRead + 1 ReDim Preserve AllTeams(TeamsRead) AllTeams(TeamsRead) = tmpTeam Loop

This might need a few changes.. a bit tired here.. and I'm basically writing from memory..
__________________
IFL - Vermont Mountaineers

~ I am an idiot, walking a tight rope of fortunate things ~

Last edited by Coder : 12-16-2006 at 06:28 PM. Reason: Forgot a few things
Coder is offline   Reply With Quote
Old 12-16-2006, 06:35 PM   #3
Oilers9911
College Benchwarmer
 
Join Date: Jan 2006
Thanks alot man. I'll give that a try.

Quote:
Originally Posted by Coder View Post
Liverpool,Anfield,60,70
Arsenal, Emirate Stadium, 99,99


You must be an Arsenal supporter
Oilers9911 is offline   Reply With Quote
Old 12-16-2006, 06:39 PM   #4
Coder
College Prospect
 
Join Date: Nov 2000
Location: Gothenburg, Sweden
Quote:
Originally Posted by Oilers9911 View Post
Thanks alot man. I'll give that a try.



You must be an Arsenal supporter


Chelsea,Toilet,1,1

__________________
IFL - Vermont Mountaineers

~ I am an idiot, walking a tight rope of fortunate things ~
Coder is offline   Reply With Quote
Old 12-16-2006, 06:43 PM   #5
daedalus
Pro Rookie
 
Join Date: Oct 2000
Quote:
Originally Posted by Coder View Post
Liverpool,Anfield,60,70
Arsenal, Emirate Stadium, 99,99
You are CORRECT, sir!
daedalus is offline   Reply With Quote
Old 12-16-2006, 06:51 PM   #6
Oilers9911
College Benchwarmer
 
Join Date: Jan 2006
Quote:
Originally Posted by Coder View Post
Chelsea,Toilet,1,1


I would have gone with Shithole but yeah I agree.
Oilers9911 is offline   Reply With Quote
Old 12-16-2006, 06:53 PM   #7
Oilers9911
College Benchwarmer
 
Join Date: Jan 2006
Now I assume I can do something similar with the fixture list. I would like to assign each team a number from 1 to 20 and then have the fixtures look like this:

1,20
2,19
3,18

with the home side listed first. Then at the end of the season renumber all the teams so that the fixtures change. Does that sound right?
Oilers9911 is offline   Reply With Quote
Old 12-16-2006, 06:53 PM   #8
Oilers9911
College Benchwarmer
 
Join Date: Jan 2006
Quote:
Originally Posted by daedalus View Post
You are CORRECT, sir!

In that case after today it would be Portsmouth 99,99 right?
Oilers9911 is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is On
Forum Jump


All times are GMT -5. The time now is 10:45 AM.



Powered by vBulletin Version 3.6.0
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.