Skip to main content

Dialog Box will keep closing

If have follows the Turorial: Dialog Project Part 2 Keeping dialog open - YouTube
But somehow the Box keeps on closing. Does anybody have a Idea why this is happening?
Option Explicit
Dim sFilename As String
Dim bExitScript As Boolean
 
Sub Main
Call menu()
End Sub
 
Function menu()
Dim dlg As DialogDemo
Dim button As Integer
 
button = Dialog(dlg)
If button = 0 Then bExitScript = True
End Function
 
Function displayIt(ControlID$, Action%, SuppValue%)
Dim bExitMenu As Boolean
 
Select Case Action%
Case 1
 
Case 2
Select Case ControlID$
 
Case "OKButton1"
 
Case "CancelButton1"
End Select
End Select
 
If bExitMenu Then
displayIt = 0
Else
displayIt = 1
End If
End Function
 

Brian Element Thu, 08/31/2023 - 15:30

Hi Mightyyy

Here is the additional code to keep the dialog open.


Option Explicit
Dim sFilename As String
Dim bExitScript As Boolean

Sub Main
	Call menu()
End Sub

Function menu()
	Dim dlg As DialogDemo
	Dim button As Integer
	
	button = Dialog(dlg)
	If button = 0 Then bExitScript = True
End Function

Function displayIt(ControlID$, Action%, SuppValue%)
	Dim bExitMenu As Boolean
	
	Select Case Action%
		Case 1
		
		Case 2
			Select Case ControlID$
				
				Case "OKButton1"
					bExitMenu = True
				
				Case "CancelButton1"
					bExitMenu = True
			End Select		
	End Select
	
	If bExitMenu Then
		displayIt = 0
	Else
		displayIt = 1
	End If
End Function

In the attached file I also added two additional buttons, if you now select them the dialog won't close, if you select the OK or Cancel button it will close.

The website encountered an unexpected error. Try again later.