Ive made a program, but I'm having trouble getting it to store a value and compare it with the previous entered value. I would really appreciate if someone could tell me what I would need to add (not code but another if/then or another loop etc.)
The problem is that the results show me the last number I entered, and not the actual smallest and largest values.
I've tried nesting an if / then statement in the subs smallest and largest, but I realized why that wouldn't worked. I'm really stumped, any help is appreciated!
Module Module1 Sub Main() Dim userNum, smallest, largest As Integer showintro() Do Console.Write("Please enter a number: ") userNum = CInt(Console.ReadLine()) If userNum <= -99 Then subSmallest(userNum, smallest) ElseIf userNum > -99 Then subLargest(userNum, largest) End If Loop Until userNum = -99 displayResults(smallest, largest) End Sub Sub showintro() Console.writeline("This program will get all of the numebers you enter ") console.writeline("and determine the smallest and largest Number") Console.writeline("When you are finished inputing your numbers, enter -99") End Sub Sub subSmallest(ByRef userInput As Integer, ByRef smallestNumber As Integer) smallestNumber = userInput End Sub Sub subLargest(ByRef userNumber As Integer, ByRef largestNumber As Integer) largestNumber = userNumber End Sub Sub displayResults(ByVal smallestNumber As Integer, ByVal largestNumber As Integer) Console.WriteLine("The Smallest Number is: " & smallestNumber & " the Largest Number is: " & largestNumber) End Sub End Module
This post has been edited by GunnerInc: 27 September 2012 - 04:37 PM
Reason for edit:: Fixed broken code tags