Go Back  Xtreme Visual Basic Talk > Visual Basic .NET (2002/2003/2005/2008, including Express editions) > .NET General > Array Question.


Reply
 
Thread Tools Display Modes
  #1  
Old 07-10-2012, 03:36 AM
KrisDwyer's Avatar
KrisDwyer KrisDwyer is offline
Newcomer
 
Join Date: Jun 2008
Posts: 20
Default 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?
Reply With Quote
  #2  
Old 07-10-2012, 03:50 AM
PlausiblyDamp's Avatar
PlausiblyDamp PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Wigan, UK
Posts: 1,692
Default

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?
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
  #3  
Old 07-10-2012, 04:06 AM
KrisDwyer's Avatar
KrisDwyer KrisDwyer is offline
Newcomer
 
Join Date: Jun 2008
Posts: 20
Default

Player, Team and League are the arrays.

The rest are variables

For the first iteration of this occuring:

Playercount = 100
Teamcount = 100
Leaguecount = 1
Reply With Quote
  #4  
Old 07-10-2012, 04:15 AM
Flyguy's Avatar
Flyguy Flyguy is offline
Lost Soul

Super Moderator
* Guru *
 
Join Date: May 2001
Location: Vorlon
Posts: 18,929
Default

Either Team(), League() or PlayerCount is a string (array).
Reply With Quote
  #5  
Old 07-10-2012, 04:16 AM
KrisDwyer's Avatar
KrisDwyer KrisDwyer is offline
Newcomer
 
Join Date: Jun 2008
Posts: 20
Default

Yeah, they are all string arrays.

The purpose of it is, that some data is integer, and the rest is characters.
Reply With Quote
  #6  
Old 07-10-2012, 04:27 AM
KrisDwyer's Avatar
KrisDwyer KrisDwyer is offline
Newcomer
 
Join Date: Jun 2008
Posts: 20
Default

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.
Reply With Quote
  #7  
Old 07-10-2012, 05:28 AM
PlausiblyDamp's Avatar
PlausiblyDamp PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Wigan, UK
Posts: 1,692
Default

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?
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
  #8  
Old 07-10-2012, 07:45 AM
KrisDwyer's Avatar
KrisDwyer KrisDwyer is offline
Newcomer
 
Join Date: Jun 2008
Posts: 20
Default

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!
Reply With Quote
  #9  
Old 07-10-2012, 08:24 AM
PlausiblyDamp's Avatar
PlausiblyDamp PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Wigan, UK
Posts: 1,692
Default

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.
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
Reply


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

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 Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->