.NET

Reply
Mentor
mgorecki
Posts: 414
Registered: ‎09-23-2004
Message 1 of 3 (106 Views)
Accepted Solution

Dialog Launches Regardless of "If, The"

106 Views, 2 Replies
06-15-2012 11:06 AM

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_LicenseCheck.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\Standard 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,

Mark

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
            Application.ShowModalDialog(dialogAddDelete)
        End If

 

Cheers,

 

Maritn.

Active Contributor
DesignProQuig
Posts: 32
Registered: ‎03-02-2012
Message 2 of 3 (97 Views)

Re: Dialog Launches Regardless of "If, The"

06-15-2012 12:45 PM in reply to: mgorecki

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
            Application.ShowModalDialog(dialogAddDelete)
        End If

 

Cheers,

 

Maritn.

http://www.designprosoftware.co.uk/
Mentor
mgorecki
Posts: 414
Registered: ‎09-23-2004
Message 3 of 3 (93 Views)

Re: Dialog Launches Regardless of "If, The"

06-15-2012 01:19 PM in reply to: DesignProQuig

Hi Martin,

Thank you for the suggestion.  I used the msgbox and found where my issue was.  It's all cleared up now.

 

Best regards,

Mark

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.