Jimmy_A
asked on
VB Arrays
Hi,
Just trying to figure out how to do this with a VB array. I want an array that does the equivalent of this PHP code:
$db_array[1][0] = username
$db_array[1][1] = userid
$db_array[1][2] = email
Where the first number in the [] would go up from 1 to however number of users I have. The second number in the [] would mean the username [0], userid [1] or email [2] of that first number.
Make sense?
Thanks a lot :-), and let me know if you need clarification. I know I've been pretty vague, but I'm unsure as how I should explain it ;-).
Just trying to figure out how to do this with a VB array. I want an array that does the equivalent of this PHP code:
$db_array[1][0] = username
$db_array[1][1] = userid
$db_array[1][2] = email
Where the first number in the [] would go up from 1 to however number of users I have. The second number in the [] would mean the username [0], userid [1] or email [2] of that first number.
Make sense?
Thanks a lot :-), and let me know if you need clarification. I know I've been pretty vague, but I'm unsure as how I should explain it ;-).
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You might want to redim from 0 instead of 1. That depends on what you are doing. You know something like this:
People.nPeople = 2
Redim People.Person(1 To (People.nPeople-1)) As UserType
People.Person(0).Username = "Jim"
People.Person(0).UserID = "JJ"
People.Person(0).Email = "jj@aol.com"
People.Person(1).Username = "Nancy"
People.Person(1).UserID = "Nan"
People.Person(1).Email = "nan@aol.com"
It really is no different, but some people like to start from 0 instead of 1 (or whatever).
I recommend using types because it makes it easier for you to handle the data as you start to pass it around your program. Like if you want to deal with one person then you just pass one variable of type UserType. Instead of having to pass three variables for each field that you associate with the person. There are a lot of other reasons to be using types instead of splitting your data up into multiple arrays. Anyway, its just a suggesting.
Opps....I didn't redim that previous message from 0. It still redim'ing from 1. Though I did change the upper bounds. The line:
Redim People.Person(1 To (People.nPeople-1)) As UserType
Should have read:
Redim People.Person(0 To (People.nPeople-1)) As UserType
If you wanted to start at 0 instead of 1. There are probably other typos since I didn't test anything. Still, you get the jist of what I am suggesting.
ASKER
Whoa, this is what I call service :-). I wake up, and already have this many answers to my question.
I've ended up using the types Enlade detailed (which work perfectly by the way), so have given you the 50 points. I've learnt stuff some all of the other methods, so I've increased the points and split the extra points among the rest of you.
Thanks again! This has been very helpful.
I've ended up using the types Enlade detailed (which work perfectly by the way), so have given you the 50 points. I've learnt stuff some all of the other methods, so I've increased the points and split the extra points among the rest of you.
Thanks again! This has been very helpful.
Darko