Dialog Box will keep closing

2 posts / 0 new
Last post
Mightyyy
Offline
Joined: 08/28/2023 - 02:43
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's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

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.