Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27184

VS 2008 Student Test Score Final project

$
0
0
I've been trying to finish this program for my final project. This is the following code I have. Everything works but when I hit the calculate button all I get is 0 on all the grade averages. I can't figure out what I've done wrong. Help please!! Due by 12

Public Class frmGradform

Public Function IsValid(ByVal num As Integer) As Integer
If num >= 0 And num <= 100 Then
Return (num)
Else
Return ("Please try again,")
End If
End Function
Dim std(6) As Student
Private Sub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripMenuItem.Click
Dim filename As String = InputBox("Enter filename : ", "Filename prompt", "output.txt")
Dim sw As IO.StreamWriter = IO.File.CreateText(filename)

For i = 0 To 5
sw.WriteLine(std(i).studentName)
sw.WriteLine(std(i).testScores(0))
sw.WriteLine(std(i).testScores(1))
sw.WriteLine(std(i).testScores(2))
sw.WriteLine(std(i).testScores(3))
sw.WriteLine(std(i).testScores(4))
sw.WriteLine(std(i).average)
Next

sw.Close()
MessageBox.Show(filename & " file created successfully", "DONE")
End Sub

Private Sub GenerateReportToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GenerateReportToolStripMenuItem.Click
Dim str As String = ""
For i = 0 To 5
str &= std(i).studentName & vbTab
str &= std(i).testScores(0) & vbTab
str &= std(i).testScores(1) & vbTab
str &= std(i).testScores(2) & vbTab
str &= std(i).testScores(3) & vbTab
str &= std(i).testScores(4) & vbTab
str &= std(i).average & vbNewLine
Next
MessageBox.Show(str, "Report")
End Sub

Private Sub BtnDisplay_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
For intCount = 0 To 5
std(intCount) = New Student()
ReDim std(intCount).testScores(4)
Next

Try
std(0).studentName = txtName1.Text
std(0).testScores(0) = IsValid(Convert.ToInt32(txtS11.Text))
std(0).testScores(1) = IsValid(Convert.ToInt32(txtS12.Text))
std(0).testScores(2) = IsValid(Convert.ToInt32(txtS13.Text))
std(0).testScores(3) = IsValid(Convert.ToInt32(txtS14.Text))
std(0).testScores(4) = IsValid(Convert.ToInt32(txtS15.Text))
std(1).studentName = txtName2.Text
std(1).testScores(0) = IsValid(Convert.ToInt32(txtS21.Text))
std(1).testScores(1) = IsValid(Convert.ToInt32(txtS22.Text))
std(1).testScores(2) = IsValid(Convert.ToInt32(txtS23.Text))
std(1).testScores(3) = IsValid(Convert.ToInt32(txtS24.Text))
std(1).testScores(4) = IsValid(Convert.ToInt32(txtS25.Text))
std(2).studentName = txtName3.Text
std(2).testScores(0) = IsValid(Convert.ToInt32(txtS31.Text))
std(2).testScores(1) = IsValid(Convert.ToInt32(txtS32.Text))
std(2).testScores(2) = IsValid(Convert.ToInt32(txtS33.Text))
std(2).testScores(3) = IsValid(Convert.ToInt32(txtS34.Text))
std(2).testScores(4) = IsValid(Convert.ToInt32(txtS35.Text))
std(3).studentName = txtName4.Text
std(3).testScores(0) = IsValid(Convert.ToInt32(txtS41.Text))
std(3).testScores(1) = IsValid(Convert.ToInt32(txtS42.Text))
std(3).testScores(2) = IsValid(Convert.ToInt32(txtS43.Text))
std(3).testScores(3) = IsValid(Convert.ToInt32(txtS44.Text))
std(3).testScores(4) = IsValid(Convert.ToInt32(txtS45.Text))
std(4).studentName = txtName5.Text
std(4).testScores(0) = IsValid(Convert.ToInt32(txtS51.Text))
std(4).testScores(1) = IsValid(Convert.ToInt32(txtS52.Text))
std(4).testScores(2) = IsValid(Convert.ToInt32(txtS53.Text))
std(4).testScores(3) = IsValid(Convert.ToInt32(txtS54.Text))
std(4).testScores(4) = IsValid(Convert.ToInt32(txtS55.Text))
std(5).studentName = txtName6.Text
std(5).testScores(0) = IsValid(Convert.ToInt32(txtS61.Text))
std(5).testScores(1) = IsValid(Convert.ToInt32(txtS62.Text))
std(5).testScores(2) = IsValid(Convert.ToInt32(txtS63.Text))
std(5).testScores(3) = IsValid(Convert.ToInt32(txtS64.Text))
std(5).testScores(4) = IsValid(Convert.ToInt32(txtS65.Text))

Catch ex As Exception
MessageBox.Show("Please Enter a Value from 0-100.")
End Try

For intCount = 0 To 5
std(intCount).average = 0
For intCount1 = 0 To 4
std(intCount).average += std(intCount).testScores(intCount1)
Next
std(intCount).average /= 5
Next

txtAvg1.Text = std(0).average.ToString("n2")
txtAvg2.Text = std(1).average.ToString("n2")
txtAvg3.Text = std(2).average.ToString("n2")
txtAvg4.Text = std(3).average.ToString("n2")
txtAvg5.Text = std(4).average.ToString("n2")
txtAvg6.Text = std(5).average.ToString("n2")

For count = 0 To 5
Dim stdRecord As String
stdRecord = std(count).studentName
For count1 = 0 To 4
stdRecord += " " + std(count).testScores(count1).ToString("n2")
Next
stdRecord += "" + std(count).average.ToString()
Next
End Sub

Private Sub FileToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FileToolStripMenuItem.Click

End Sub

Private Sub GenerateReportToolStripMenuItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GenerateReportToolStripMenuItem.Click

End Sub

Private Sub SaveToolStripMenuItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripMenuItem.Click

End Sub
Public Class Student
Public Property studentName() As String

Get

End Get
Set(ByVal value As String)

End Set
End Property
Public testScores() As Integer
Public Property average() As Decimal
Get

End Get
Set(ByVal value As Decimal)

End Set
End Property

End Class

Private Sub txtName1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtName1.TextChanged

End Sub

Private Sub frmGradform_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub
End Class

Viewing all articles
Browse latest Browse all 27184

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>