?
Solved

Display the smallest and largest number entered

Posted on 2012-04-09
3
Medium Priority
?
434 Views
Last Modified: 2012-06-21
I havea majority of the program written and need assistant working the bugs out need to display the smallest and largest number entered to display. Working in VB6
0
Comment
Question by:gorean4u
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 

Author Comment

by:gorean4u
ID: 37825411
Here is what i have so far


Private Sub cmdInput_Click()
    'Declare Variables
    Dim intNumber As Integer
    Dim intAverage As Integer
    Dim strAverage As String
    Dim lngSum As Long
    Dim strSum As String
    Dim intCounter As Integer
    Dim strCounter As String
    Dim strDisplayTotal As String
    Dim strDisplayAverage As String
    Dim strDisplaySum As String
    Dim strDisplayMin As String
    Dim strDisplayMax As String
    Dim strMin As String
    Dim strMax As String
    Dim intMin As Integer
    Dim intMax As Integer
    Dim varNumber As Integer
   
    'Initialize variables
    intCounter = 0
    lngSum = 0
   
   'Input Numbers
    Do
        intNumber = Val(InputBox("Enter an Integer (0 to Quit): ", _
            "input Number"))
       
        If (intNumber > 0) Then
            lngSum = lngSum + intNumber
            intCounter = intCounter + 1
        End If
       
        If intNumber > varNumber Then
            intNumber = intMax
        End If
       
        If intNumber < varNumber Then
            intNumber = intMin
        End If
           
     Loop Until (intNumber = 0)
   
    intAverage = lngSum / intCounter
   
    'Store results
    strAverage = Format(intAverage, "###")
    strCounter = Format(intCounter, "#####")
    strSum = Format(lngSum, "#####")
    strMin = Format(intMin, "#####")
    strMax = Format(intMax, "#####")
   
    strDisplayTotal = "numbers entered: " & strCounter
    strDisplaySum = "Sum of numbers: " & strSum
    strDisplayAverage = "Average of numbers: " & strAverage
    strDisplayMin = "Smallest Number entered: " & strMin
    strDisplayMax = "Largest Number entered: " & strMax
   
   
   
    'Display results
    lblTotal.Caption = strDisplayTotal
    lblSum.Caption = strDisplaySum
    lblAverage.Caption = strDisplayAverage
    lblMin.Caption = strDisplayMin
    lblMax.Caption = strDisplayMax
    lblTotal.Visible = True
    lblSum.Visible = True
    lblAverage.Visible = True
    lblMin.Visible = True
    lblMax.Visible = True
   
End Sub
0
 

Author Comment

by:gorean4u
ID: 37825624
Any takers, please
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 2000 total points
ID: 37825723
Change this:
        If (intNumber > 0) Then
            lngSum = lngSum + intNumber
            intCounter = intCounter + 1
        End If
        
        If intNumber > varNumber Then
            intNumber = intMax
        End If
        
        If intNumber < varNumber Then
            intNumber = intMin
        End If

Open in new window


To This:
        If (intNumber > 0) Then
            lngSum = lngSum + intNumber
            intCounter = intCounter + 1

            If intCounter = 1 Then
                intMin = intNumber
                intMax = intNumber
            Else
                If intNumber < intMin Then
                    intMin = intNumber
                End If

                If intNumber > intMax Then
                    intMax = intNumber 
                End If        
            End If
        End If        

Open in new window

0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Originally published Entrepreneur.com Booming numbers of freelancing professionals are changing the face of work. In the United States alone last year, the number of workers freelancing grew from 700,000 to 54 million, according to a Freelancers’…
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
Articles on a wide range of technology and professional topics are available on Experts Exchange. These resources are written by members, for members, and can be written about any topic you feel passionate about. Learn how to best write an article t…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question