SetOption Method Example

This example uses the SetOption method to change the value of two registry keys based on input from the user. The SetOption method only overrides the stored registry values for the current application. The stored settings will remain unchanged and will be the only values visible to the user through REGEDIT.EXE.

Sub SetOptionX()

   Dim intExclusiveDelay As Integer
   Dim intSharedDelay As Integer

   ' Get user input for new values of ExclusiveAsyncDelay 
   ' and SharedAsyncDelay registry keys.
   intExclusiveDelay = Val(InputBox("Enter a new value " & _
      " for the ExclusiveAsyncDelay registry key " & _
      "(in milliseconds):"))
   intSharedDelay = Val(InputBox("Enter a new value " & _
      "for the SharedAsyncDelay registry key " & _
      "(in milliseconds):"))

   If intExclusiveDelay > 0 And intSharedDelay > 0 Then
      ' Change values of registry keys.
      SetOption dbExclusiveAsyncDelay, intExclusiveDelay
      SetOption dbSharedAsyncDelay, intSharedDelay
      MsgBox "Registry keys changed to new values " & _
         "for duration of program."
   Else
      MsgBox "Registry keys left unchanged."
   End If

End Sub