-
i don't really undertstand the basics about functions ... i tried making one for my program but i don't get the value i want ...
average = ((((mp1 + mp2 + mp3 + mp4) * 2) + (midt + final)) / 10)
Call test
lblyraverage.Caption = average & " " & "[" & letter & "]"
the letter value never comes up ... i just have the average
---by the way the line with "average" is one whole line ... n the variables r dimmed ... i just didn't copy those things to this thread
my function looks like this:
Public Function test()
Dim letter As String
Select Case average
Case Is >= 97
letter = "A+"
Case Is >= 93
letter = "A"
Case Is >= 90
letter = "A-"
Case Is >= 87
letter = "B+"
Case Is >= 83
letter = "B"
Case Is >= 80
letter = "B-"
Case Is >= 77
letter = "C+"
Case Is >= 73
letter = "C"
Case Is >= 70
letter = "C-"
Case Is >= 65
letter = "D"
Case Is >= 60
letter = "F"
Case Is >= 0
letter = "F-"
End Select
End Function
how come i don't get the letter value?
-
Have you tried an ELSE statement with other resulting letter in you SELECT?
Roger
-
Nearly there, You just missed out one line just before End Function you need to putthis tells the function to return the value in letter.
-
nope
no that didn't work ... i wonder y it won't give out the letter value ...
-
You wrote Select Case average Where did this "Avergae" come from? In order to use it in your Function, you must pass it through.
Code:
Public Function test(average)
'Enter the rest of your code here...
test = letter 'Return the letter
End Function
To call it, pass average through it. This should print out an -A
Code:
MyAverage = 92
RetVal = text (MyAverage)
Print RetVal