twoshortm
asked on
largest/smallest Array Value
I am using Visual basic.net 2005 with windows XP. I am writing a program that needs to find the largest/smallest array values. The user has to enter 10 numbers and then have the numbers displayed. After that the largest and smallest value are displayed. This is what i know i need to put in but i am not exactly sure on how to get started.
Dim numbers(50) as Integer
Dim count As Integer
dim highest as integer
highest = numbers
for count = 1 To (numbers.Length -1)
If numbers(count) > highest Then
highest = numbers(count)
end if
next count
I know to find the smallest is similar.
thank you lisa
Dim numbers(50) as Integer
Dim count As Integer
dim highest as integer
highest = numbers
for count = 1 To (numbers.Length -1)
If numbers(count) > highest Then
highest = numbers(count)
end if
next count
I know to find the smallest is similar.
thank you lisa
ASKER CERTIFIED 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
Yes that works but what if you want to display the numbers the user enters in a listbox and can't you display the min and max results as a label.
To whom are you directing your question to Idle_Mind or myself?
I don't think it matters Fernando...all the info is there...she just needs to modify it.
Idle_Mind; I just am not sure whose code she is working from.
ASKER
from both of you guys. Both solution work but i wanted to know how to display the numbers the user entered into a listbox and then display the min/max value in a label.
To add something to a ListBox:
ListBox1.Items.Add("someth ing")
To set a Label:
Label1.Text = "set"
We can't do everything for you. I feel badly enough as this looks like homework now that I think about it..
ListBox1.Items.Add("someth
To set a Label:
Label1.Text = "set"
We can't do everything for you. I feel badly enough as this looks like homework now that I think about it..
Dim numbers() As Integer = {22, 12, 33, 74, 9, 18, 1, 99, 44, 2}
to what you had it;
Dim numbers(50) as Integer
And fill the array in with the values from the user. I did the above just to test the code.