 |
 |

07-10-2012, 03:36 AM
|
 |
Newcomer
|
|
Join Date: Jun 2008
Posts: 20
|
|
Array Question.
|
Ok, so i've got this piece of code here...
Code:
Player(Team(League(LeagueCount, TeamCount), PlayerCount), 1) = PlayerFirst.Text
I'm trying to send data to an array, using the value of a variable in another array. (Basically, rather than using multidimensional arrays, I'm using arrays that work with each other).
However the error i'm getting is - Conversion from string "" to type 'Integer' is not valid
Where am I going wrong?
|
|

07-10-2012, 03:50 AM
|
 |
Ultimate Contributor
Forum Leader * Expert *
|
|
Join Date: Nov 2003
Location: Wigan, UK
Posts: 1,692
|
|
|
Without knowing the variable types for the things in the code it is going to be hard to pinpoint exactly where the problem lies.
How many of those variables are arrays?
|
|

07-10-2012, 04:06 AM
|
 |
Newcomer
|
|
Join Date: Jun 2008
Posts: 20
|
|
|
Player, Team and League are the arrays.
The rest are variables
For the first iteration of this occuring:
Playercount = 100
Teamcount = 100
Leaguecount = 1
|
|

07-10-2012, 04:15 AM
|
 |
Lost Soul
Super Moderator * Guru *
|
|
Join Date: May 2001
Location: Vorlon
Posts: 18,931
|
|
|
Either Team(), League() or PlayerCount is a string (array).
|
|

07-10-2012, 04:16 AM
|
 |
Newcomer
|
|
Join Date: Jun 2008
Posts: 20
|
|
|
Yeah, they are all string arrays.
The purpose of it is, that some data is integer, and the rest is characters.
|
|

07-10-2012, 04:27 AM
|
 |
Newcomer
|
|
Join Date: Jun 2008
Posts: 20
|
|
To give a better idea, this is the preceding line to save the "team"
Code:
Team(League(LeagueCount, TeamCount), 1) = TeamName.Text
This actually works.
|
|

07-10-2012, 05:28 AM
|
 |
Ultimate Contributor
Forum Leader * Expert *
|
|
Join Date: Nov 2003
Location: Wigan, UK
Posts: 1,692
|
|
My immediate reaction is to suggest that arrays are not the right tool for the job here, even the simpler code setting the team name is quite difficult to follow.
In the code
Code:
Team(League(LeagueCount, TeamCount), 1)
what is the number 1 representing?
|
|

07-10-2012, 07:45 AM
|
 |
Newcomer
|
|
Join Date: Jun 2008
Posts: 20
|
|
It was my fault, don't worry I've sorted it out now!
What the problem was, was that i had not set the variables for the initializing of the array, thus it was trying to access Team("", PlayerCount)!
Thanks for your help guys! 
|
|

07-10-2012, 08:24 AM
|
 |
Ultimate Contributor
Forum Leader * Expert *
|
|
Join Date: Nov 2003
Location: Wigan, UK
Posts: 1,692
|
|
|
Even though it is working I would suggest that Arrays are not the right tool for the job, arrays of arrays of arrays are going to get confusing and messy very quickly.
I would personally have defined a class for each of the major entities Team, Player, League and exposed collections from the appropriate object e.g. A League would have a collection of Teams, a team a collection of players and so on.
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|