![]() | Type | Description | ||
| NewValue as Variant | A Variant expression that holds the new value for the editor. |
The ValueChanged event is fired just before changing the editor's Value property. The ValueChanged event notifies your application that the value of the editor is changing. The FindItem property gets the caption associated to a value if the editor contains a predefined list ( DropDownList ).
The following sample shows how to restore the old value after user changes the editor's data:
Option Explicit
Dim iChanging As Long
Private Sub Editor1_ValueChanged(NewValue As Variant)
If (iChanging = 0) Then
With Editor1
NewValue = .Value
End With
End If
End Sub
Private Sub Form_Load()
iChanging = 0
With Editor1
.EditType = DropDownList
.AddItem 1, "One"
.AddItem 2, "Two"
iChanging = iChanging + 1
.Value = 1
iChanging = iChanging - 1
End With
End SubThe following sample displays the newly value:
Option Explicit
Dim iChanging As Long
Private Sub Editor1_ValueChanged(NewValue As Variant)
With Editor1
Debug.Print "The user changes the editor's value to " & NewValue
End With
End Sub
Private Sub Form_Load()
iChanging = 0
With Editor1
.EditType = DropDownList
.AddItem 1, "One"
.AddItem 2, "Two"
iChanging = iChanging + 1
.Value = 1
iChanging = iChanging - 1
End With
End Sub