Alright, I have read and searched but I dont understand what a validating event is and how I use it for this program. Basically, I am trying to make sure that text in 3 dif textboxes is btween 0 and 100 and if its not, I need to change the forecolor to red . Can someone let me know if I am on the right track? My prob. right now is changing the forecolor.
Thanks
Jen

VB Code:
  1. Private mblngrade As Boolean
  2.     Private Sub CalcButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CalcButton.Click
  3.         'declare variables
  4.         Dim decTest1, decTest2, decTest3, decAverage As Decimal
  5.         Dim strID, strName, strGrade As String
  6.         Dim blnGrade As Boolean
  7.         'assign value to variables
  8.         decTest1 = Val(Me.Test1TextBox.Text)
  9.         decTest2 = Val(Me.Test2TextBox.Text)
  10.         decTest3 = Val(Me.Test3TextBox.Text)
  11.  
  12.         strID = Me.IDTextBox.Text
  13.         strName = Me.StudentTextBox.Text
  14.         mblnGrade = ValidGrade(decTest1, decTest2, decTest3)
  15.         decAverage = (decTest1 + decTest2 + decTest3) / 3
  16.         'display Grade
  17.  
  18.         If blnGrade = True Then
  19.             Me.AverageDisplay.Text = decAverage
  20.         Else
  21.             MessageBox.Show("This value must be between 0 and 100.", "Average", _
  22.             MessageBoxButtons.OK, MessageBoxIcon.Information)
  23.         End If
  24.     End Sub
  25.  
  26.     Function ValidGrade(ByRef dec1 As Decimal, ByRef dec2 As Decimal, ByRef dec3 As Decimal) As Boolean
  27.         'delcare varaible for boolean value
  28.         Dim blnGrade As Boolean
  29.  
  30.         If dec1 >= 0 And dec1 <= 100 Then
  31.             If dec2 >= 0 And dec2 <= 100 Then
  32.                 If dec3 >= 0 And dec3 <= 100 Then
  33.                     Return True
  34.                 Else : Return False
  35.                 End If
  36.             End If
  37.         End If
  38.  
  39.     End Function
  40.  
  41.  
  42.  
  43.  
  44.  
  45.     Private Sub ClearButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearButton.Click
  46.         'clear the textboxes
  47.         Me.StudentTextBox.Text = ""
  48.         Me.IDTextBox.Text = ""
  49.         Me.Test1TextBox.Text = ""
  50.         Me.Test2TextBox.Text = ""
  51.         Me.Test3TextBox.Text = ""
  52.         Me.AverageDisplay.Text = ""
  53.         Me.GradeLabel.Text = ""
  54.     End Sub
  55.    
  56.     'Validate TextBoxes and change forecolor to red if data is invalid
  57.     Private Sub Test1TextBox_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles Test1TextBox.Validating, Test2TextBox.Validating, _
  58.     Test3TextBox.Validating
  59.         If mblngrade = True Then
  60.             e.Cancel = False
  61.         End If
  62.     End Sub
  63.  
  64.     Private Sub ExitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitButton.Click
  65.         Me.Close()
  66.     End Sub
  67. End Class