OK, I did search for help on this, but I probably did not use the correct verbage. Here's what I have so far: I have to write an application that reads five integers and determints and prints the largest and the smallest integers in a group. I cannot use array's etc.. I must use what we have learned up to this point, which is If..Else statements. I have a conceptual idea of what to do, and have it working with only two numbers (no brainer right) If I make five variables and then check to see if each subsequent number is greater than or equal to the previous number, then I should come up the the largest to smallest?? I have commented out the number4 - 5 to keep the debugger complaing, I figured I can just add them later. Here is the code that I have come up with to date.
CODE
Module SortNumbers
Sub Main()
Dim number1 As Integer
Dim number2 As Integer
Dim number3 As Integer
'Dim number4 As Integer
'Dim number5 As Integer
'read in the first number
Console.Write("Enter the first Number")
number1 = Console.ReadLine()
'read in the second number
Console.WriteLine("Enter the second Number")
number2 = Console.ReadLine()
'read in the third number
Console.WriteLine("Enter the third Number")
number3 = Console.ReadLine()
If number2 >= number1 Then 'check to see if number2 is larger than or equal to number1
Console.WriteLine(number2 & " " & number1) ' if it is than write that to the console
Else : Console.WriteLine(number1 & " " & number2) ' or if number1 is bigger than print this message
End If
If number3 >= number2 Then 'If the third number is larger than the 2nd number
Console.WriteLine(number3 & " " & number2 & " " & number1) ' this is where I am stuck.
ElseIf number Then
End If
End Sub
End Module
I considered making more variables like:
CODE
dim first
dim second
dim third
dim fourth
dim fifth
and then assigning the "number*" variable to the other first - fifth variable, but I thought I was getting a little more involved with it. I wish I had picked this up a 22 instead of 43 years old. I was hoping my old vb6 (from 1998) credits would still be good, but... Thanks for any small contribution. I know I'ts just one little thing, and I do remember doing something like this with array's in Java back in the day. But I don't program on a daily basis.
Richard