|
-
Jun 26th, 2000, 04:54 AM
#1
Thread Starter
Hyperactive Member
shorter code
although my program is pretty simple it might be hard for me to explain it ...
my program's only purpose in life is to get me my final average of the whole year of any class ... this was pretty simple at first because my school used # grades n all i had to do was plug in those #'s into a formula ...
however, for some reason my school changed to the letter grade system ... i know that i can easily type the # i think would be closest to the letter grade n not worry about making a whole new program ...
however, i just want to use the combo-box n select the letter grade that i get ... now the letter grades go from a+, a, a-, b+, b, b-, c+, c, c-, d, f, f- ...
now for me to get my final grade i have to add my 4 marking period grades n multiply them by 2 n add that to the sum of my midterm n final exam n divide the whole thing by 10 ...
however, its going to be a hassle just to get the value of one marking period grade cause i'm gonna have to check what letter is in the combo-box (which r 12 letters which means i'm gonna have to check which letter it is until it is the right one) n then turn it into a # value ...
now that's a lot of coding just to find one marking period grade by using letters ... n don't forget that after i find that one i have to find the other 5 grades (2,3,4 marking period n midterm n final) ...
so does anyone know of a way that i can cut this coding down to size ... or else i'll be spending a lot of time coding ... any help is appreciated
-
Jun 26th, 2000, 05:04 AM
#2
Lively Member
Could you use the listindex property of the combo box to calculate the grade value on the fly?
i.e. a+ is combo1.list(0), up to f- is combo1.list(11)
So you could do something like
Code:
Grade=(12-Combo1.ListIndex)*8.333
Which would make an a+ = 100, and an f- = 8.333 (You could alter this function to make the f- = 0 and the a+ = 100 or whatever), and then perform the rest of your calculations on the result.
-
Jun 26th, 2000, 05:19 AM
#3
_______
///
problem...how do you declare a+ or a-
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Jun 26th, 2000, 05:30 AM
#4
You mean as in they might cause conflicts with the operators + and -? Then you can name them Ap and Am. p stands for Plus and m stands for minus.
-
Jun 26th, 2000, 05:49 AM
#5
Thread Starter
Hyperactive Member
good idea but
andrew your solution is a good idea but the # values i need to get can't come out with the formula ... at least i don't see how ...
a+ = 97, a = 93, a- = 90, b+ = 87, b = 83, b- = 80,
c+ = 77, c = 73, c- = 70, d = 65, f = 60, f- = 50
i don't think changing any #'s in the formula u mentioned can give me those exact letter values ...
-
Jun 26th, 2000, 06:08 AM
#6
_______
...Ap Am A
another approach is to use public Constants
ie.bas module
Public Ap,A,Am as Integer
Public Const Ap = 97
Public Const A = 93
Public Const Am = 90
then just use the values as you would numbers
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Jun 26th, 2000, 06:44 AM
#7
Put them in an Enum to reduce time.
-
Jun 26th, 2000, 08:41 AM
#8
Lively Member
You could use the ItemData property of the ComboBox when you add the grades at the beginning
Code:
Private Sub Form_Load()
With Combo1
.AddItem "A+", 0: .ItemData(0) = 97
.AddItem "A", 1: .ItemData(1) = 93
.AddItem "A-", 2: .ItemData(2) = 90
.AddItem "B+", 3: .ItemData(3) = 87
.AddItem "B", 4: .ItemData(4) = 83
.AddItem "B-", 5: .ItemData(5) = 80
.AddItem "C+", 6: .ItemData(6) = 77
.AddItem "C", 7: .ItemData(7) = 73
.AddItem "C-", 8: .ItemData(8) = 70
.AddItem "D", 9: .ItemData(9) = 65
.AddItem "F", 10: .ItemData(10) = 60
.AddItem "F-", 11: .ItemData(11) = 50
.ListIndex = 0
End With
End Sub
Private Sub Combo1_Click()
Grade = Combo1.ItemData(Combo1.ListIndex)
'(Or whatever you want to do with it)
End Sub
-
Jun 26th, 2000, 08:55 AM
#9
Fanatic Member
If you go as far as to enumerate the values then give them proper names for easier reading later.
Code:
Enum GradesInfo
gradeAPlus = 97
gradeA = 93
gradeAMinus = 90
gradeBPlus = 87
gradeB = 83
etc etc
DocZaf
{;->
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|