Help! Sub-procedure to Function
Hi im supposed to put a button in a worksheet, such that when you click the button, the main code(for this question) will be executed.
Option Explicit
'Writen by Jada Al-Aswad
Sub A5Q1a(ByVal NG As Single, ByVal LG As String)
If (NG >= 90) Then
LG = "A"
ElseIf (NG >= 60) Then
LG = "B"
Else
LG = "C"
End If
End Sub
Sub A5Q1Main()
Dim StudentNG As Single
Dim StudentLG As String
Dim StudentName As String
StudentLG = "F"
StudentNG = 52 'Please replace this NG by your first two digits of your student #
StudentName = "Jada Al-Aswad" 'Please replace this Name by your name
Call A5Q1a(StudentNG, StudentLG)
MsgBox ("The final grade of " & StudentName & ": " _
& StudentNG & " => " & StudentLG)
End Sub
Apparently there's a mistake here but i have no idea what it is.. this program is to to write a program to convert your numeric grade (NG) to letter grade (LG). The input is your NG and the output is your LG. Then i have to change the sub-procedure to a function to solve the same problem. Suppose the input is NG, and the return value of the function is LG.
HELPP :(
Re: Help! Sub-procedure to Function
lg should be passed byref
to make into function
vb Code:
function lg(ng as single) as string
'your code
' must set value for lg
end function
difference for function is that it should return something to the caller, either a value, as in this case, or success /failure of the function
studentlg = lg(studentng)