VBA Password Input with Cancel Function

the standard InputBox returns empty fields and cancel the same way

No it does not. It returns a null pointer (vbNullString) on cancel and an empty string ("") for empty input.

Dim s As String
s = InputBox("Test")

If StrPtr(s) = 0 Then
  'Cancel pressed
Else
  'Ok pressed
End If

Because InputBoxDK returns the InputBox‘s value unchanged, same logic applies to it.

Leave a Comment