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

VS 2010 How to tell which Textbox Event was fired (Enter vs. Leave on single private sub)

$
0
0
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


Viewing all articles
Browse latest Browse all 27554

Trending Articles



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