vb dot net arrays

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Dec 2008
Posts: 14
Reputation: asif786 is an unknown quantity at this point 
Solved Threads: 0
asif786 asif786 is offline Offline
Newbie Poster

vb dot net arrays

 
0
  #1
Jan 3rd, 2009
i want to store multiple values in an array. lets say the variable name is voternumber which is a unique number that is generated which is between 1 and 5000. i will output the voternumber to a voter and then as them to input it so that i can perform a check to see wether it has been used before or not. To do this i will need to store all the unique voter numbers, i do not know how to do this i know of arrays but dont know how to add to them b clicking buttons.

Please help and elaborate by giving an example. thanks a lot. if not using arrays could you please explain any other method.
Last edited by asif786; Jan 3rd, 2009 at 12:15 pm.
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: vb dot net arrays

 
0
  #2
Jan 3rd, 2009
- List or ArrayList can be used for better reasons. and It contains .Contains method which to be used in your case.
- Use Random class to generate numbers but check if the generated number is has been generated before or not.
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: vb dot net arrays

 
0
  #3
Jan 3rd, 2009
  1. Dim numbers As List(Of Int32)
  2. while(numbers.Count > 100)
  3. {
  4. if Not numbers.Contains(GetRandomNumber())
  5. numbers.Add(GetRandomNumber())
  6. }
Last edited by Ramy Mahrous; Jan 3rd, 2009 at 3:26 pm. Reason: I wrote C# code instead of VB.NET!
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC