Hi im trying to do this projexct for class. Here is the code
Public Class Form1
Dim index As Integer = 0
Structure Gradebook
Dim ID As Integer
Dim Exam1 As Integer
Dim Exam2 As Integer
Dim Exam3 As Integer
Dim Avgg As Integer
Dim LG As Char
End Structure
Dim Student(10) As Gradebook
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Student(index).ID = Val(TextBox1.Text)
Student(index).Exam1 = Val(TextBox2.Text)
Student(index).Exam2 = Val(TextBox3.Text)
Student(index).Exam3 = Val(TextBox4.Text)
Student(index).Avgg = Avg(Student(index).Exam1, Student(index).Exam2, Student(index).Exam3)
Dim grade As Integer = Val(Student(index).Avgg)
Student(index).LG = Lettergrade(grade)
index = +1
TextBox1.Text = Nothing
TextBox2.Text = Nothing
TextBox3.Text = Nothing
TextBox4.Text = Nothing
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim formatstg As String = "{0,-15}{1,20}{2,20}{3,20}{4,20}{5,20}"
ListBox1.Items.Add(String.Format(formatstg, "ID", "Exam1", "Exam2", "Exam3", "Avg", "LetterGrade"))
For X As Integer = 0 To 10
ListBox1.Items.Add(String.Format(formatstg, Student(X).ID, Student(X).Exam1, Student(X).Exam2, Student(X).Exam3, Student(X).Avgg, Student(X).LG))
Next
End Sub
Function Avg(ByVal Grade1 As Double, ByVal Grade2 As Double, ByVal Grade3 As Double) As Double
Return ((Grade1 + Grade2 + Grade3) / 3)
End Function
Function Lettergrade(ByVal Numgrade As Integer) As Char
If Numgrade < 70 Then
Return "F"
ElseIf Numgrade < 80 Then
Return "C"
ElseIf Numgrade < 90 Then
Return "B"
ElseIf Numgrade <= 100 Then
Return "A"
End If
End Function
End Class
Here is the Form when it is running http://gyazo.com/a5436577e6e0b703aba77f9913027d55
As you can tell the Zones are not the way it is supposto to be. I tried changing
Dim formatstg As String = "{0,-15}{1,20}{2,20}{3,20}{4,20}{5,20}"
So many times but nothing works. If any one could help i would appreciate it!!