| | |
Need Help With Problem please
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Dec 2007
Posts: 2
Reputation:
Solved Threads: 0
sorry if this is really nooby but i cant seem to get pass the basics.
i need to write a program that accepts a series of exam marks, ended by -1. When the -1 is entered, it should display the following results in a text box,:
i need to write a program that accepts a series of exam marks, ended by -1. When the -1 is entered, it should display the following results in a text box,:
The average (mean) mark
The smallest and largest mark.
"Great work" if at least 30% of the students passed (got 40% or above). If not, it should display "High failure rateThank you for any help you cant offer
use the following code. before use it take three textboxes(text1,trxt2,text3); one listbox(list1) ; one label(label1); and a commandbutton(command1)
see the screenshot also
hope this will help you
regards
Shouvik
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Option Explicit Private Sub Command1_Click() Dim num As Integer num = 0 begin: num = InputBox("Enter exam marks. -1 to end", "Marks") If num > -1 Then List1.AddItem num GoTo begin End If Text1.Text = "Max :" & GetMaxMark Text2.Text = "Min :" & GetMinMark Text3.Text = "Avg :" & GetAvg Call Result End Sub Public Function GetMaxMark() As Integer 'to find out the maximum mark Dim i As Integer, max As Integer max = 0 For i = 0 To List1.ListCount - 1 Step 1 If Val(List1.List(i)) > max Then max = Val(List1.List(i)) End If Next i GetMaxMark = max End Function Public Function GetMinMark() As Integer 'to find out the minimum mark Dim i As Integer, min As Integer min = List1.List(0) For i = 0 To List1.ListCount - 1 Step 1 If Val(List1.List(i)) < min Then min = Val(List1.List(i)) End If Next i GetMinMark = min End Function Public Function GetAvg() As Double 'to find out the average Dim i As Integer, sum As Integer sum = 0 For i = 0 To List1.ListCount - 1 Step 1 sum = sum + Val(List1.List(i)) Next i GetAvg = sum / List1.ListCount GetAvg = Format(GetAvg, "0.00") End Function Public Sub Result() 'to print the overall result status Dim i As Integer, above40 As Integer, per As Double above40 = 0 For i = 0 To List1.ListCount - 1 Step 1 If Val(List1.List(i)) >= 40 Then above40 = above40 + 1 End If Next i per = (above40 * 100) / List1.ListCount If per >= 30 Then Label1.Caption = "GREAT WORK" & vbCrLf & "Passing Rate :" & per & "%" Else Label1.Caption = "HIGH FAILURE RATE" & vbCrLf & "Passing Rate :" & per & "%" End If End Sub
see the screenshot also
hope this will help you
regards
Shouvik
Shouvik_The_Expert_Coder
Have a problem? Don't worry just give me a call and I'll fix it for you.
Have a problem? Don't worry just give me a call and I'll fix it for you.
![]() |
Similar Threads
- Problem with Windows Update and WinXP (Web Browsers)
- Installing Windows 98 On VMware. Floppy problem (Windows 95 / 98 / Me)
- Windows XP keeps restarting since a new video card (Windows NT / 2000 / XP)
- Redhat Linux 6.2 - ipop3d problem? (*nix Software)
- Problem with T720 (Cellphones, PDAs and Handheld Devices)
- Connection Problems (Networking Hardware Configuration)
- Encoding (Unicode) problem in IE 6.0 (Web Browsers)
- .htaccess mod_rewrite problem (Linux Servers and Apache)
- Javascript/HTML problem!!! (JavaScript / DHTML / AJAX)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Help needed with VB Assignment
- Next Thread: play .wav file with data
Views: 939 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for Visual Basic 4 / 5 / 6
* 6 429 2007 access activex add age append application basic beginner birth bmp c++ calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver struct subroutine table tags textbox timer urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





