Attribute VB_Name = "mStrPtr" '************************************************************************************************************************************************************* Rem Informations ' mStrPtr.bas ' Purpose ' Sample to use function StrPtr() ' Content address of String variable (String pointer). ' 2016-01-10 ' Jean-Michel ' https://www.alcya.com/vba-strptr.html ' mailto:renseignements@alcya.com ' Compatibility ' VBA 6 Yes ' VBA 7 Yes ' Win 32 Yes ' Win 64 Yes ' Mac Don't Know ' Office ' 11.0 2003 X ' 12.0 2007 X ' 13.0 2010 X ' 14.0 2013 X ' Tools ' Modules ' ' Usage ' 1. How i determine if user choose "Cancel" button or "Ok" button with empty string. ' Use undocumented function StrPtr(). ' 2. ' StrPtr content memory address of InputBox variable. ' If user choose "Cancel" button, StrPtr() = 0. ' If user choose "Ok" button, StrPtr() = variable address. ' Update ' Date Author Purpose Comment ' 2015-03-09 Jean-Michel Create this module ' '************************************************************************************************************************************************************* ' Rem Header Option Explicit Option Base 0 ' Default LBound. Option Compare Binary '************************************************************************************************************************************************************* ' Rem Declaration ' Constants ' Debug Private Const cs_ModuleName As String = "mStrPtr" '***************************************************************************Code Begin************************************************************************* ' Rem Routines '============================================================================================================================================================= ' InputBoxExt ' Purpose ' 1. This InputBox() know if you choose "Cancel" button or "Ok" button with empty string. ' Notes ' 1. Use undocumented function StrPtr(). '============================================================================================================================================================= Public Sub InputBoxExt() Dim Response As String, myStrAddress As Long Response = InputBox("Valeur ?") myStrAddress = StrPtr(Response) If (myStrAddress = 0) Then ' Button "Cancel". MsgBox "You choose Cancel button." Else ' Button "Ok". If (Response = "") Then ' User not write a value. MsgBox "You choose Ok button, but the variable Response at address " & myStrAddress & " is empty !", vbCritical Else MsgBox "You choose value : " & Response End If ' Response = "" End If ' Adresse = 0 End Sub ' '***************************************************************************Code End**************************************************************************