Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
I want to find smallest number from more than 100 numbers using vb6.
Posted
Comments
fjdiewornncalwe 28-Nov-11 16:37pm    
You have our permission to do so if that is what you want.
Please ask a question after you have tried something. We aren't here to just dump you a code solution.
LanFanNinja 28-Nov-11 18:28pm    
LOL!! :)
Orcun Iyigun 28-Nov-11 19:54pm    
This question sounds more like a homework assignment to me..

Iterate through the numbers, and keep track of the smallest one you've found so far. At the end, you'll have the smallest. I don't know VB6 but the method is fairly straight forward.
 
Share this answer
 
v2
Comments
LanFanNinja 28-Nov-11 18:37pm    
+5 Agreed.
Try this codes:

C#
int lowest = 2147483647;
int[] nums = {4,2,1,74,6,77};
foreach(int num in nums)
{
   if(num < lowest)
   {
      lowest = num;
   }
}


Regards,
Eduard
 
Share this answer
 
v2
Comments
LanFanNinja 29-Nov-11 0:29am    
I give you a +3 for posting a valid solution. However your solution is in C# where as the OP was asking for VB6.

I also want to point out that setting the integer variable "lowest" to the value "2147483647" is unnecessary.

I would like to offer the following alternative to your code.
int[] nums = { 4, 2, 1, 74, 6, 77 };
int lowest = nums[0];
for (int i = 1; i < nums.Length; i++)
{
if (nums[i] < lowest)
{
lowest = nums[i];
}
}

Please do not take this the wrong way your code is fine this is merely a suggestion.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900