Matrix Games Forums

Forums  Register  Login  Photo Gallery  Member List  Search  Calendars  FAQ 

My Profile  Inbox  Address Book  My Subscription  My Forums  Log Out

Question about Dynamic Arrays..

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
  Printable Version
All Forums >> [Current Games From Matrix.] >> [Sports] >> Maximum-Football 2.0 >> 3rd Party Developers Area >> Question about Dynamic Arrays.. Page: [1]
Login
Message << Older Topic   Newer Topic >>
Question about Dynamic Arrays.. - 4/14/2006 3:34:37 AM   
Magnum357

 

Posts: 613
Joined: 4/22/2005
Status: offline
I need some advice by anybody with some Database programming experience. I'm working on a schedule utility program for MaxFB and I'm running into a problem. The utility works ok and can edit a leagues schedule, but my program only displays the Team ID number in a listbox instead of the Teams actual team name.

My problem is that I can't find a way to store the team names from a League Database and then load them into Listbox so they display the Team names and not the Team ID numbers. I was thinking about using a Dyamic Array because since a league Database can have virtually an unlimited amount of Teams in the league, I would need to have an unlimited amount of Varibles to store the there names in. Unless somebody has a better solution, Dynamic Arrays are the only thing I can think of that would allow me to do this. Can anybody give a small example of how too use a Dynamic Array?

< Message edited by Magnum357 -- 4/14/2006 3:35:20 AM >
Post #: 1
RE: Question about Dynamic Arrays.. - 4/14/2006 4:23:42 AM   
MjH

 

Posts: 165
Joined: 2/23/2006
Status: offline
You don't say what language you're using, but I googled using "dynamic array microsoft" and got the following as the first result:

http://www.microsoft.com/technet/scriptcenter/guide/sas_vbs_hbsi.mspx?mfr=true

If you're using VBScript, then that appears to be a pretty straight-forward example.

(in reply to Magnum357)
Post #: 2
RE: Question about Dynamic Arrays.. - 4/14/2006 2:49:33 PM   
Magnum357

 

Posts: 613
Joined: 4/22/2005
Status: offline
Ah, I forgot to point that out, thanks. I'm using VB6 to build the utility, and this link you gave does offer some more detail about Dynamic Arrays then I have had before, but it doesn't seem to give much info on how to do this for Databases.

(in reply to MjH)
Post #: 3
RE: Question about Dynamic Arrays.. - 4/14/2006 4:04:35 PM   
MjH

 

Posts: 165
Joined: 2/23/2006
Status: offline
First a disclaimer: All the coding I have done in the past decade has been in Oracle PL/SQL and Java, so I have no clue about Visual Basic, therefore what I'm proposing may not be the best way to do what you want in VB.

However, I assmume that VB has way of returning a list of rows when executing a query against a database. What I would do would be something like (note, most of the following is psuedo-code, not actual VB syntax):

  sqlStatement = "SELECT T.ID, T.TeamName FROM Teams T, LeagueDivisions L WHERE T.DivisionId = L.ID ORDER BY L.Name, T.TeamName";
  listOfRows = executeQuery(sqlStatement);
  
  Dim teamNameArray()
  Dim teamIDArray()
  teamSize = 0;
  
  while (listOfRows has another entry) do
    listOfRows.next

    ReDim Preserve teamNameArray(teamSize)
    ReDim Preserve teamIDArray(teamSize)

    teamNameArray(teamSize) = listOfRows.TeamName
    teamIDArray(teamSize) = listOfRows.ID
    teamSize = teamSize + 1
  end while;


You now have two arrays, one with the team names, and one with the team ids. Use the teamNameArray to build your list box, and when the user selects an entry in the list, you can use the index of that team in the teamNameArray to find the ID in the teamIDArray to use in other queries.

Does that help any?

(in reply to Magnum357)
Post #: 4
RE: Question about Dynamic Arrays.. - 4/15/2006 2:25:09 AM   
Magnum357

 

Posts: 613
Joined: 4/22/2005
Status: offline
Hey, that is quite helpful code. Thanks. I will give it a try and see how it will work out in my program. Now, I just got too think of how too get the loaded TeamName Data to display in the listbox where the Team Indexes are. I think your code above hints at that, but I don't quite understand it.

(in reply to MjH)
Post #: 5
RE: Question about Dynamic Arrays.. - 4/15/2006 5:06:59 AM   
Antmeister71

 

Posts: 31
Joined: 3/1/2006
Status: offline
quote:

ORIGINAL: Magnum357

I need some advice by anybody with some Database programming experience. I'm working on a schedule utility program for MaxFB and I'm running into a problem. The utility works ok and can edit a leagues schedule, but my program only displays the Team ID number in a listbox instead of the Teams actual team name.

My problem is that I can't find a way to store the team names from a League Database and then load them into Listbox so they display the Team names and not the Team ID numbers. I was thinking about using a Dyamic Array because since a league Database can have virtually an unlimited amount of Teams in the league, I would need to have an unlimited amount of Varibles to store the there names in. Unless somebody has a better solution, Dynamic Arrays are the only thing I can think of that would allow me to do this. Can anybody give a small example of how too use a Dynamic Array?


Okay, if I am understanding correctly, you want to load the data from an existing database into a listbox, but show and store the data from a specific field in the other database. VB6 should be able to do this. I wish I could remember the correct properties, but look for something along the lines of "Bound" and "Display". These two properties should give you a way to select other fields. What you will be basically doing is treating that table and as look-up table to get the team names. I had been programming in VB and Access for years, but it has been a while since I moved over to online databases such as PHP/mySQL and an open source database application such as Database in OpenOffice.

In other words, an array is not necessary for what you are trying to do.

< Message edited by Antmeister71 -- 4/15/2006 5:07:55 AM >


_____________________________

ALMARKS.COM Master Link Directory
http://www.almarks.com/masterlinks/

(in reply to Magnum357)
Post #: 6
RE: Question about Dynamic Arrays.. - 4/15/2006 7:54:04 AM   
Magnum357

 

Posts: 613
Joined: 4/22/2005
Status: offline
Hmm... so I really don't need an Array for this at all? I tried looking for "Bounds" in the property lists of Recordsets, but I couldn't find anything like that, maybe I'm looking in the wrong place. You don't mean "UBound" and stuff like that for Arrays right?

(in reply to Antmeister71)
Post #: 7
RE: Question about Dynamic Arrays.. - 4/15/2006 9:22:36 AM   
Antmeister71

 

Posts: 31
Joined: 3/1/2006
Status: offline
quote:

ORIGINAL: Magnum357

Hmm... so I really don't need an Array for this at all? I tried looking for "Bounds" in the property lists of Recordsets, but I couldn't find anything like that, maybe I'm looking in the wrong place. You don't mean "UBound" and stuff like that for Arrays right?


I am not sure if the verbage has changed in the past few years, but there should be a property in that list box that allows you to choose which field you want to extract info from which I believe was called "Bound" (at least it was in Access). And there was a another property called Display which allow you to display whatever field you wanted in the same record. Let me go check out info on the net to see if I am just multilating the current verbage.

_____________________________

ALMARKS.COM Master Link Directory
http://www.almarks.com/masterlinks/

(in reply to Magnum357)
Post #: 8
RE: Question about Dynamic Arrays.. - 4/15/2006 10:58:16 AM   
Antmeister71

 

Posts: 31
Joined: 3/1/2006
Status: offline
Okay, here we go. Geez, I was off with the verbage because I was thinking about the listbox control in the applications I am using now. Here are two properties you can look at that should help you out.

DataField Property
ItemData Property


I provided both because I am not sure how you will create it, but if you read up on these links it does discuss those bound controls. Sorry for confusing the hell out you, but I hope this helps out.

By the way here is the info for the ListBox control here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/VBRef98/html/vbmscLROverview.asp

You may or may not be aware of it already, but I just posted the last link just in case.


< Message edited by Antmeister71 -- 4/15/2006 11:00:01 AM >


_____________________________

ALMARKS.COM Master Link Directory
http://www.almarks.com/masterlinks/

(in reply to Antmeister71)
Post #: 9
Page:   [1]
All Forums >> [Current Games From Matrix.] >> [Sports] >> Maximum-Football 2.0 >> 3rd Party Developers Area >> Question about Dynamic Arrays.. Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts


Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI

4.359