Resume Layout(False) End Sub #End Region Private Sub Text Box1_Text Changed(By Val sender As System.
Text Changed End Sub Public Sub Text Box1_Validating(By Val sender As Object, _ By Val e As System.
The sequence is the same regardless of how the end user moves the input focus away from the control. NET controls fire these events in the same sequence only if end users move the input focus by means of the keyword; if they use the mouse, the control fires a Lost Focus event, then the Validating event, and – if the validation fails – another Got Focus event to let the application know that the focus is again on the control. NET programs created by VB Migration Partner follow the . In most cases, the fact that the Lost Focus event fires before the Validate event doesn’t affect the application negatively.
Text = "") End Sub Now consider the corresponding VB. If the end user clicks on a different control and Text1 contains an empty string, the Lost Focus event resets the background color to white, then the Validate event cancels the focus shift, and finally the Got Focus event changes the background color to yellow again. If this is the case, the converted code might fail or behave unexpectedly.
In such cases, you can force the controls in the support library to behave more closely to the original VB6 controls by setting the VB6Config.
Back Color = vb Yellow End Sub Private Sub Text1_Lost Focus() Text1.
Back Color = vb White End Sub Private Sub Text1_Validate(Cancel as Boolean) Cancel = (Text1. In some applications, however, the code in the Text1_Lost Focus method might depend on some variable that has been set in the Validate event.
NET controls is in the order in which they fire the Lost Focus and Validate events.
VB6 controls fire the Validate event first and then the Lost Focus event; if the Validate sets Cancel=True, then the Lost Focus event is never fired. New() 'This call is required by the Windows Form Designer. Label 'Required by the Windows Form Designer Private components As System. Container 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. Run(form1) End Sub End Class Public Class Form1 Inherits System. Protected Overloads Overrides Sub Dispose(By Val disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components. Dispose(disposing) End Sub Friend With Events Text Box1 As System. Printing Public Class Main Class Shared Sub Main() Dim form1 As Form = New Form1() Application. Initialize Component() 'Add any initialization after the Initialize Component() call End Sub 'Form overrides dispose to clean up the component list. Focus Event Support static property to True: When this property is True, the support library ensures that the Lost Focus event is always fired after the Validate event.