If this is even possible or the right way to do it I would like to have one sub that handles multiple textboxes on there ENTER and LEAVE events. If the text was changed it would save the underlying data source. Below is my current coding under two subs where I have declared the variables at the beggining of the class.
Code:
Private Sub QuantityTextBox_TextEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles QuantityTextBox.Enter, DrawingNumberTextBox.Enter, PartRevisionTextBox.Enter
EditQty = QuantityTextBox.Text
EditDrawing = DrawingNumberTextBox.Text
EditRevision = PartRevisionTextBox.Text
End Sub
Private Sub QuantityTextBox_TextLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles QuantityTextBox.Leave, DrawingNumberTextBox.Leave, PartRevisionTextBox.Leave
Dim QtyEdit As String = QuantityTextBox.Text
Dim DrawingEdit As String = DrawingNumberTextBox.Text
Dim RevisionEdit As String = PartRevisionTextBox.Text
Dim NeedToSave As Boolean = False
If Not EditQty = QtyEdit Then
Dim Input As String = "(Qty revised by " & Inspector & "|From|" & EditQty & "|To|" & QtyEdit & ")"
If Not NotesTextBox.Text.Contains(Input) Then
NotesTextBox.Text = NotesTextBox.Text & vbNewLine & Input
NeedToSave = True
End If
End If
If Not EditDrawing = DrawingEdit Then
Dim Input As String = "(Drawing revised by " & Inspector & "|From|" & EditDrawing & "|To|" & DrawingEdit & ")"
If Not NotesTextBox.Text.Contains(Input) Then
NotesTextBox.Text = NotesTextBox.Text & vbNewLine & Input
DrawingNumber = DrawingEdit
NeedToSave = True
End If
End If
If Not RevisionEdit = EditRevision Then
Dim Input As String = "(Revision revised by " & Inspector & "|From|" & EditRevision & "|To|" & RevisionEdit & ")"
If Not NotesTextBox.Text.Contains(Input) Then
NotesTextBox.Text = NotesTextBox.Text & vbNewLine & Input
Revision = RevisionEdit
NeedToSave = True
End If
End If
If NeedToSave = True Then
SaveRIMaster_Click(Me, EventArgs.Empty)
End If
End Sub