Web Development



need your help about an array macro in WORD.

By melodytang0214 ·
need your help about an array macro in WORD.
Dear all,
I am a beginner of VBA programming and I have some problems with an array macro,plz help !!!

the array stores student ID and student Name and the macro will enable me to enter the student ID and student Mark in a form, and it will show up " student *** has a mark of ***".
this is my script:

Public arStuID( As String
Public arStudMark( As Integer

Sub startit()

arStuID(1) = "Tim"
arStuID(2) = "Jim"
arStuID(3) = "Dim"
arStuID(4) = "Tam"
arStuID(5) = "Tom"
arStuID(6) = "Tum"
arStuID(7) = "Lim"
arStuID( = "Nee"


End Sub

Sub PrintAllMarks()


For x = 1 To 8
If x = arStuID(x) Then
Selection.TypeText "Student " & arStuID(x) _
& " has a mark of " & arStudMark(x) & "." & vbCrLf
End If
Next x

End Sub

but the problem is even if I didn't supply a certain student ID and his mark, the document still show a line" student has a mark of 0"
how should I code to show only the inputed student ID and mark ??

thanks !!!

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Share your knowledge

Related Discussions

Related Forums