Queues

koure

Active member
Joined
Sep 23, 2008
Messages
27
Programming Experience
Beginner
Hi

Im new to vb.net and I m using a queue to my program to queue the client name. The problem is that I want to queue the client id as well in a row. For example

queue(0) = Mark, 764
queue(1) = John , 345

is there any way to do that?

thanks in advance
 
Sure, there are multiple ways of doing this, I'll explain 2 of them.
1. Store strings in the queue and use a special character (something that would never appear in someone's name or ID), like the tilde "~". When putting items into the queue:
queue.Add(ClientName & "~" & ClientID) which would be "Mark~764" for example. Then go get the data back, use String.Split("~") to get a two element array being:
NextClient() = CStr(queue.GetNextItem()).Split("~")
NextClient(0) is the Name and NextClient(1) is the ID

2. Make a class that has 2 properties: Name and ID. After filling in the two properties, add it to the queue. Obviously to get them back, use the classes properties.
 
thanks for your reply

Which is the best one to use. I mean in terms of performance and speed?

thanks
 
Performance and speed? I dunno, easy to make and maintain, I'd go with making a quick, small class.
 
Back
Top