I want the code to determine if there is more than one layout in the drawing (not including "Model"). After it determines if there is only one, or if there is more than one page, then do actions based on the boolean variable.
If there is only one page, then do some actions. If there is more than one page, launch the dialog and do some actions.
Regardless of the number of pages, it always launches the dialog box. I even put a breakpoint at the beginning of the code and it still launches the dialog.
Is there a way to force it so the dialog only gets launched if the "If, Then" criteria is met?
Here is partial code:
Public Sub ADP() Dim diaAddDelete As New dialogAddDelete Dim pageOption As String = String.Empty Dim pageNumber As String = String.Empty Dim pageToCopy As String = String.Empty Dim sourceLayerExists As Boolean Dim selectedLayerIDs As ObjectIdCollection ' Check to see if the license file exists 'Currently this is not working, so the license check is removed ' Dim strAmkorLicense As String = "\\\\chaznas03\\lib\\AutoCAD\\VB_Net\\AMKR_License
Check.txt" 'If (System.IO.File.Exists(strAmkorLicense)) Then ' If only one page exists in the drawing, create a new layout by using a the layout "EMPTY" from the "Standard Template.dwt" drawing Dim isOnlyOnePage As Boolean = True ' Check to see if the drawing has more than one page isOnlyOnePage = checkNumberOfLayouts() If isOnlyOnePage = True Then ' Dim templateFileName As String, templateLayoutName As String ' templateFileName = "\\chaznas03\support\DsnTools\DocPro\Format\Standa rd Template.dwt" ' templateLayoutName = "EMPTY" ' importLayout(templateFileName, templateLayoutName) End If If isOnlyOnePage = False Then ' If more than one page exists, use the dialog box to Add or Delete a page If diaAddDelete.ShowDialog = System.Windows.Forms.DialogResult.OK Then pageOption = diaAddDelete.newPageOption
I even set the boolean to "True" and it still launched the dialog.
Thanks for any help on this,
Solved! Go to Solution.
Check the return vale of function checkNumberOfLayouts() with a message box to see what it's returning.
Also this line of code shows how you can condition if your dialog opens or not:
' Diaglog only loads if this value is true.
Dim TestBool As Boolean = False
Dim myForm As New dialogAddDelete
If TestBool = True Then
Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register
Start with some of our most frequented solutions to get help installing your software.