0% found this document useful (0 votes)
181 views

"" "" "" "One of The Fields Is Filled Incorrectly!"

This document contains the code for a student form application that allows a user to add student records with an ID, subject, and grade. It stores the records in a multi-dimensional array and includes buttons to add, clear, and print records. It also contains code to display messages and open additional forms like a print preview, about box, and legend.

Uploaded by

sumukhs
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
181 views

"" "" "" "One of The Fields Is Filled Incorrectly!"

This document contains the code for a student form application that allows a user to add student records with an ID, subject, and grade. It stores the records in a multi-dimensional array and includes buttons to add, clear, and print records. It also contains code to display messages and open additional forms like a print preview, about box, and legend.

Uploaded by

sumukhs
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Public Class studentForm

Private strStudents(9, 2) As String

Private Sub addButton_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles addButton.Click
Static intRow As Integer = 0
If studentIDTextBox.Text = "" Or subjectTextBox.Text = "" Or
gradeTextBox.Text = "" Then
MessageBox.Show("One of the fields is filled incorrectly!")
Else : With Me
strStudents(intRow, 0) = .studentIDTextBox.Text
strStudents(intRow, 1) = .subjectTextBox.Text
strStudents(intRow, 2) = .gradeTextBox.Text
End With
intRow += 1

studentIDTextBox.Clear()
subjectTextBox.Clear()
gradeTextBox.Clear()
studentIDTextBox.Focus()
MessageBox.Show("Your entry has been added!")
End If
End Sub

Private Sub printButton_Click(ByVal sender As Object, ByVal e As


System.EventArgs) Handles printButton.Click
Me.PrintPreviewDialog1.ShowDialog()
End Sub

Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As


System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim sngTopLocation, sngLeftLocation, sngTopMargin As Single
sngTopMargin = e.MarginBounds.Top
sngLeftLocation = e.MarginBounds.Left
sngTopLocation = sngTopMargin
Dim MyFont As New Font("Calibri", 15)
Dim sngLineHeight As Single = MyFont.Height * 1.2
sngTopLocation += sngLineHeight
e.Graphics.DrawString("Student
Subject Grade (%)", MyFont, Brushes.Black,
sngLeftLocation, sngTopLocation)
sngTopLocation += (sngLineHeight * 3)
e.Graphics.DrawLine(Pens.Black, sngLeftLocation, sngTopLocation,
e.MarginBounds.Right, sngTopLocation)
Dim intCounter, intUpperbound As Integer
intUpperbound = strStudents.GetUpperBound(0)
For intCounter = 0 To intUpperbound
If strStudents(intCounter, 0) <> String.Empty Then
Dim strItem As String
strItem = String.Format("{0}
{1} {2}%", _
strStudents(intCounter, 0), strStudents(intCounter, 1),
strStudents(intCounter, 2))
e.Graphics.DrawString(strItem, MyFont, Brushes.Black,
sngLeftLocation, sngTopLocation)
sngTopLocation += sngLineHeight
End If
Next
' draw line and print average
e.Graphics.DrawLine(Pens.Black, sngLeftLocation, sngTopLocation,
e.MarginBounds.Right, sngTopLocation)
End Sub

Private Sub exitButton_Click(ByVal sender As Object, ByVal e As


System.EventArgs) Handles exitButton.Click
MessageBox.Show("Are you sure you want to exit?")
MessageBox.Show("Are you really sure you want to exit? You might need
permission from an administrator... Click here to get permission and exit.")
Me.Close()
End Sub

Private Sub studentForm_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load

End Sub

Private Sub clearButton_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles clearButton.Click
studentIDTextBox.Clear()
subjectTextBox.Clear()
gradeTextBox.Clear()
studentIDTextBox.Focus()
End Sub
Private Sub clearDatabaseButton_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs)

End Sub

Private Sub FileToolStripMenuItem_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles FileToolStripMenuItem.Click

End Sub

Private Sub AddToolStripMenuItem_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles AddToolStripMenuItem.Click
Static intRow As Integer = 0
If studentIDTextBox.Text = "" Or subjectTextBox.Text = "" Or
gradeTextBox.Text = "" Then
MessageBox.Show("One of the parameters are filled incorrectly")
Else : With Me
strStudents(intRow, 0) = .studentIDTextBox.Text
strStudents(intRow, 1) = .subjectTextBox.Text
strStudents(intRow, 2) = .gradeTextBox.Text
End With
intRow += 1

studentIDTextBox.Clear()
subjectTextBox.Clear()
gradeTextBox.Clear()
studentIDTextBox.Focus()
MessageBox.Show("Your entry has been added!")
End If
End Sub
Private Sub ClearToolStripMenuItem_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles ClearToolStripMenuItem.Click
studentIDTextBox.Clear()
subjectTextBox.Clear()
gradeTextBox.Clear()
studentIDTextBox.Focus()
End Sub

Private Sub PrintViewToolStripMenuItem_Click(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
PrintViewToolStripMenuItem.Click
Me.PrintPreviewDialog1.ShowDialog()
End Sub

Private Sub CloseToolStripMenuItem_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles CloseToolStripMenuItem.Click
MessageBox.Show("Are you sure you want to exit?")
MessageBox.Show("Are you really sure you want to exit? You might need
permission from an administrator... Click here to get permission and exit.")
Me.Close()
End Sub

Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click
AboutBox1.Show()
AboutBox1.Focus()
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click
legend.Show()

End Sub

Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Label2.Click

End Sub
End Class

You might also like