In: Computer Science
VBA
In this assignment you will create a Word Macro-Enabled Document. The document will contain procedures with the following declarations:
• Sub Main()
• Sub GetGrades(grades() As Integer, total As Integer)
• Sub CreateOutput(className As String, grades() As Integer, total As Integer)
The Main sub-procedure will be the macro that initializes the task. In this procedure you will declare all necessary variables, prompt the user to enter the name of the class and the number of students, resize the grades array appropriately, then make calls to each of the other procedures in the order they are listed at the beginning of these instructions.
The GetGrades procedure will use a loop to prompt the user for the grade for each student. Also within the loop a running total of all grades will be kept.
The CreateOutput procedure will create the output shown in the demo video linked below. Think about building a single string that contains all the output information. You can then assign that string to the Text property of the ActiveDocument Range. Use the built in
Dim sclass As String
Dim nos As Integer
Dim grades() As Integer
Dim total As Integer
Private Sub main()
sclass = InputBox("Please Enter Student Class", "Class")
nos = InputBox("Enter number of students")
ReDim grades(nos)
Call GetGrades(grades(), total)
Call CreateOutPut(sclass, grades(), total)
End Sub
Sub GetGrades(grades() As Integer, total As Integer)
For i = 1 To Val(nos)
grades(i) = InputBox("Enter grade")
total = total + grades(i)
Next
End Sub
Sub CreateOutPut(className As String, grades() As Integer, total
As Integer)
MsgBox "ClassName is " & className & "Number of Students is
" & nos & "Grades " & "Total " & total
End Sub