Warning

 

Close

Confirm Action

Are you sure you wish to do this?

Confirm Cancel
Member Login
Site Notices
9/19/2017 7:27:10 PM
Posted: 6/19/2002 5:54:01 PM EDT
I've been trying to write a program and I can't get the friggen thing to work if it would save my life. If someone can help me out, there are free USGI mags involved. Here's what I'm trying to do: Write a program that will allow the user to enter a name, NAID number and two test scores from the form. Score this information in parallel arrays. Use a command button to have the user indicate to the program that the information should be stored (an Add button). You will not have more than 10 students and their information to store. The program should not allow info for more than 10 students to be entered and should tell the user tried to add the information for an 11th student’s. You will also need a control on the form for output. This control will be used by all of the following program options. This control should probably take up a fair amount of space so we can be sure to see the information on screen. Each of the following program options should be run by clicking on a command button. Display the name, NAID number, average and letter grade for all the students You must use a function to determine the average. You must use a function to determine the letter grade Display the high score from the first test and the student(s) with that score. Display the highest average score of the two tests and the student(s) with that average. You must use a function to determine the average Display the lowest average score of the two tests and the student(s) with that average. You must use a function to determine the average Make sure that the output is visible in the output control (whatever type of control it is). Meaning, maybe you need to clear/empty the output control before each program option is run. AAAAAAAAAHHHHHHHHHH!!!!! [whacko]
Link Posted: 6/19/2002 6:56:14 PM EDT
If you can convince me that this isn't a homework assignment, I'd be happy to help you out.
Link Posted: 6/19/2002 7:02:33 PM EDT
[Last Edit: 6/19/2002 7:04:09 PM EDT by Benjamin0001]
What exactly is your problem Marine Grunt.. Where exactly is the problem, Is it syntax, logic, program flow?? Be more specific..
Link Posted: 6/19/2002 7:12:21 PM EDT
Originally Posted By Hoplophile: If you can convince me that this isn't a homework assignment, I'd be happy to help you out.
View Quote
It is a homework assignment. I don't want anyone to do this for me, I just need TREMENDOUS help, becuase I am a Visual Basic retard. I can't beleive this class is required for Aviation. I'll post my code in a few minutes to see if you guys can give any tips............
Link Posted: 6/19/2002 7:18:30 PM EDT
Here's my code so far, or lack there of. I'm not getting any errors, it's just not working. The only thing I get in the pic box is: "NAID NAME SCORE GRADE DIFF" Option Explicit Const maxStudents As Integer = 10 Dim numStudents As Integer Dim Score1(1 To maxStudents) As Integer Dim Scores2(1 To maxStudents) As Integer Dim studentNames(1 To maxStudents) As String Dim average As Single Dim NAID As Integer Private Sub cmdadd_Click() If (txtname.Text = "") Then MsgBox "Please Enter Name" ElseIf (txtnaid = "") Then MsgBox "Please Enter NAID" ElseIf (txtscore1.Text = "") Then MsgBox "Please Enter First Score" ElseIf (txtscore2.Text = "") Then MsgBox "Please Enter Second Score" ElseIf (numStudents < maxStudents) Then numStudents = numStudents + 1 If numStudents = maxStudents Then cmdadd.Enabled = False End If studentNames(numStudents) = txtname.Text txtname.Text = "" txtnaid.Text = "" txtscore1.Text = "" txtscore2.Text = "" txtname.SetFocus End If End Sub Private Function HighestFirstScore() Dim x As Integer, maxValue As Integer, maxIndex As Integer Dim student As String maxValue = Score1(1) maxIndex = 1 For x = 1 To numStudents If (Score1(x) > maxValue) Then maxValue = Score1(x) maxIndex = x End If Next x student = studentNames(maxIndex) picDisplay.Print "Student with the highest score is " & student; "with a score of "; maxValue End Sub Private Function HighestAverageScore() Dim x As Integer, sum As Integer, maxValue As Integer, maxValue As Integer Dim student As String For x = 1 To numStudents sum = Score1(x) + score2(x) Next x average(x) = sum(x) / 2 average(maxIndex) = HighestAverageScore picDisplay.Print HighestAverageScore End Function Private Function LowestAverageScore() Dim x As Integer, sum As Integer, minValue As Integer, minValue As Integer Dim student As String For x = 1 To numStudents sum = Score1(x) + score2(x) Next x average(x) = sum(x) / 2 average(minIndex) = LowestAverageScore picDisplay.Print "The lowest average score was " & LowestAverageScore End Function Private Sub cmdDisplay_Click() picDisplay.Print picDisplay.Print "NAID", "Name", "Score", "Grade", "Diff" End Sub Private Function LetterGrade(inscore As Integer) As String If (inscore >= 90) Then LetterGrade = "A" ElseIf (inscore >= 80) Then LetterGrade = "B" ElseIf (inscore >= 70) Then LetterGrade = "C" ElseIf (inscore >= 60) Then LetterGrade = "D" Else LetterGrade = "F" End If End Function
Link Posted: 6/19/2002 7:24:17 PM EDT
where does your code assign the inputed values to the storage arrays? Also where does it call your average and high/low functions?
Link Posted: 6/19/2002 7:25:29 PM EDT
Whatever you end up with, send it to me, part of my job is to break programmers work. [}:D] SSD (SQL interface?)
Link Posted: 6/19/2002 7:31:22 PM EDT
Originally Posted By jz02: where does your code assign the inputed values to the storage arrays? Also where does it call your average and high/low functions?
View Quote
I think thats what I'm confused about. SSD- You have mail
Link Posted: 6/19/2002 7:44:47 PM EDT
ok, you have to actually assign the values from the data fields to their appropriate storage array spaces after all the checks on values to make sure they're not empty. If you don't do that then the program does nothing and all it does is cycle through the numbers. Also, you have to call the functions, they don't call themselves.
Link Posted: 6/19/2002 8:25:45 PM EDT
Thanks for the help. I'm getting a little closer now. I've only been at it for 7 hours now. [stick]
Link Posted: 6/19/2002 8:28:48 PM EDT
[Last Edit: 6/19/2002 8:32:10 PM EDT by Steelviper]
Actually, you may be working harder than you need to be. First off, you need an array for the averages as well. Say, Average(1 to maxStudents) as Integer. Then you need a procedure that computes the averages. Basically, a for..next loop that assigns average(x) = (score1(x) + score2(x)) / 2. The high score for test one can be done with a function that has a for..next loop that initializes to maxValue to score(1), then sees if score(x) is greater than maxValue. Highest average is the same deal, just based off of the average array. See below for example: Private Function HighestAverageScore() Dim x As Integer, maxValue As Integer maxValue = average(1) 'initializing to the first value For x = 1 To numStudents if maxValue < average(x) then maxValue = average(x) End if Next x HighestAverageScore = maxValue End Function Lowest average would be the same function, just switch to a >, and change the name to minValue, etc. The actual printing can be done in the cmd_click events. Say, make a button that says Print Highest Average called cmdPrintHigh. All it has to do is say picDisplay.Print "The Highest Average Score is " & HighestAverageScore & "." Also, your add function needs to store the data in the arrays. Assign numstudents to zero at the beginning of the program. inside your add procedure, just assign the value to the array. you're already incrementing, so you just say studentNames(numStudents) = txtname.Text score1(numstudents) = txtscore1.Text score2(numStudents) = txtscore2.text I don't have VB installed presently, so I haven't run the code through any sort of tests, I just offered the VB pseudocode to illustrate what I'm talking about. Hope I was helpful, and if you have any questions about what I'm talking about, feel free to drop me an email. Viper Out Edited to add, that theoretically you should pass any arrays your function will be working on in as parameters... but VB doesn't make you do that (and it's not entirely relevent for beginning level programming).
Link Posted: 6/19/2002 8:37:44 PM EDT
don't worry. I've spent months on assembly programs that didn't work. Sometimes it's just voodoo.
Link Posted: 6/19/2002 8:41:00 PM EDT
Originally Posted By MarineGrunt: Thanks for the help. I'm getting a little closer now. I've only been at it for 7 hours now. [stick]
View Quote
in the beginning it hurts... u got mail SSD
Top Top