A "grade" button is then to be pressed to determine the grades of the scores.
e.g.
James | 98 | High Distinction
BOb | 23 | Participation
note: High Distinction 90 and above;
Distinction 75 up to 89;
Credit 60 up to 74; and
Pass 50 up to 59,
all other students will be awarded a Participation Grade
All my code is as followed:
Public Class frmCreateArray
Dim Names(21) As String
Dim NamesCount, ListCount As Integer
Dim Ages(21) As Double
Dim AgesCount, ListCount2 As Integer
Dim Grades(21) As String
Dim GradesCount, ListCount3 As Integer
Dim Total As Double
Dim Item As Double
Private Property items As Object
Private Property MsgBox As String
Private Sub cmdEnterThisName_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdEnterThisName.Click
For Ages(AgesCount) = 1 To AgesCount
If Ages(AgesCount) >= 90 Then
Grades(GradesCount) = "High Destinction"
ElseIf Ages(AgesCount) >= 75 Then
Grades(GradesCount) = "Destinction"
ElseIf Ages(AgesCount) >= 60 Then
Grades(GradesCount) = "Credit"
ElseIf Ages(AgesCount) >= 50 Then
Grades(GradesCount) = "Pass"
ElseIf Ages(AgesCount) < 50 Then
Grades(GradesCount) = "Participation"
End If
Next
NamesCount = NamesCount + 1
Names(NamesCount) = txtNamesGoHere.Text
AgesCount = AgesCount + 1
Ages(AgesCount) = txtAgesGoHere.Text
GradesCount = GradesCount + 1
lblCounter.Text = Str(NamesCount) + " Students Entered"
lblCounter.Text = Str(AgesCount) + " Students Entered"
txtNamesGoHere.Text = "" : txtAgesGoHere.Text = ""
txtNamesGoHere.Focus()
End Sub
Private Sub frmCreateArray_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
NamesCount = 0
AgesCount = 0
GradesCount = 0
End Sub
Private Sub cmdShowListArray_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdShowListArray.Click
For Me.ListCount = 1 To NamesCount
lstListNames.Items.Add(Names(ListCount))
Next
For Me.ListCount2 = 1 To AgesCount
lstListAges.Items.Add(Ages(ListCount2))
Next
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClearAll.Click
txtNamesGoHere.Text = ""
txtAgesGoHere.Text = ""
lblavg.Text = "..."
lstListNames.Items.Clear()
lstListAges.Items.Clear()
lstGrade.Items.Clear()
lblCounter.Text = " Number of names entered"
txtNamesGoHere.Focus()
NamesCount = 0
AgesCount = 0
lblavgexplain.Text = "..."
End Sub
Private Sub btnAvg_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAvg.Click
For Each Me.Item In lstListAges.Items
Total = 0
For Me.AgesCount = 0 To AgesCount
Total = Total + Ages(AgesCount)
Next
lblavg.Text = Total / NamesCount
lblavgexplain.Text = "The average number of scores is: "
Next
End Sub
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
txtNamesGoHere.Text = ""
txtAgesGoHere.Text = ""
txtNamesGoHere.Focus()
End Sub
Private Sub btnGrade_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGrade.Click
For Me.GradesCount = 1 To AgesCount
lstGrade.Items.Add(Grades(GradesCount))
Next
End Sub
End Class
i get troubles when i press "grade" i need a way to tell VB to populate the listbox
I am very new to VB, please help
I have been stressing over this for weeks :'(

New Topic/Question
Reply



MultiQuote




|