How can I construct the array problem?

Visual BASIC array problem?

  • I am having some issues with a homework problem setting up a 1-D array. I am trying to set up an array where the user can input names of people and in the same array input a score ...show more

  • Answer:

    That's not a one-dimensional problem. In a lanuage where you can define the index to an array, you could use the students' names as the index and their grade as the value stored... BUT Visual Basic arrays are indexed (as most current languages are) from 0 to one less than the number of entries they hold... so in a single dimensional array you can't hold both a name and a score... unless you append name and score together into a single string, storing them in an array of strings. If you did that (and I do not recommend it), you would need a way to tell where the name stops and the score starts so you could split them back up and interpret them each time you use them. It's considered bad practice but it is certainly possible. What we've normally done since, maybe, the 1980s, is instead create either a multidimensional array or -- since you'd be storing two types of data values -- create two single dimension arrays: one would hold names and the other would hold the numeric score values -- and using the corresponding score value for any person would just require finding their name in the name array and accessing the cell with the same index number in the score array. Your assignment specifies _a_ 1-D array but perhaps it would be allowable to do it this way, if you're allowed to use more than one array as long as any array you use is one dimensional.

XTL7C7FS5DHHUZW74ZL6BEH2FQ at Yahoo! Answers Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.