Visual Basic

Moderators: None (Apply to moderate this forum)
Number of threads: 18013
Number of posts: 55386

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
VB HELP HELP! WHAT AM I DOING WRONG Posted by dodotwilson on 21 Nov 2004 at 12:08 AM
The question is:
Suppose the file Bid.txt contains a list of bids on a construction project. Write a program to analyze the list and report the two highest bids.
My file contains the following entries:25,000, 50,000, 28,000, 35,000

My answer is:
Private Sub cmdDisplay_Click()
Dim largest As Single, num As Single
'find largest two bid
picOutput.Cls
largest = 0
Open "C:\bid.txt" For Input As #1
Do While Not EOF(1)
Input #1, bid
If bid > largest ^ 2 Then
largest = largest ^ 2
End If
Loop
picOutput.Print "The Largest two bids are"; bid
End Sub

I'm not getting an error. the answer is 0 it is not giving me the 2 largest bids.
Report
Re: VB HELP HELP! WHAT AM I DOING WRONG Posted by chriscortereal on 21 Nov 2004 at 8:18 AM
: The question is:
: Suppose the file Bid.txt contains a list of bids on a construction project. Write a program to analyze the list and report the two highest bids.
: My file contains the following entries:25,000, 50,000, 28,000, 35,000
:
: My answer is:
: Private Sub cmdDisplay_Click()
: Dim largest As Single, num As Single
: 'find largest two bid
: picOutput.Cls
: largest = 0
: Open "C:\bid.txt" For Input As #1
: Do While Not EOF(1)
: Input #1, bid
: If bid > largest ^ 2 Then
: largest = largest ^ 2
: End If
: Loop
: picOutput.Print "The Largest two bids are"; bid
: End Sub
:
: I'm not getting an error. the answer is 0 it is not giving me the 2 largest bids.
:


If you are using a comma as a thousands seperator in you text file (don't).
Also convert the text for a string to the number format you want.

Hope that helps :)


Report
Re: VB HELP HELP! WHAT AM I DOING WRONG Posted by Bulgarian_VB on 22 Nov 2004 at 1:31 PM
: : The question is:
: : Suppose the file Bid.txt contains a list of bids on a construction project. Write a program to analyze the list and report the two highest bids.
: : My file contains the following entries:25,000, 50,000, 28,000, 35,000
: :
: : My answer is:
: : Private Sub cmdDisplay_Click()
: : Dim largest As Single, num As Single
: : 'find largest two bid
: : picOutput.Cls
: : largest = 0
: : Open "C:\bid.txt" For Input As #1
: : Do While Not EOF(1)
: : Input #1, bid

: : If bid > largest ^ 2 Then
: : largest = largest ^ 2
: : End If


Why do you square the 'largest' ???
And what do you do when 'bid' is actually larger than 'largest'??? You don't keep the largest bid anywhere ...

: : Loop
: : picOutput.Print "The Largest two bids are"; bid
: : End Sub
: :
: : I'm not getting an error. the answer is 0 it is not giving me the 2 largest bids.
: :
:
:
: If you are using a comma as a thousands seperator in you text file (don't).
: Also convert the text for a string to the number format you want.
:
: Hope that helps :)
:
:
:

Hope I helped,
Nikolay Semov




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.