CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Oct 2012
    Posts
    4

    [RESOLVED] I need help converting modal to modeless dialog boxes

    I am brand new at visual basic, and i have no clue what i am doing. i need help allowing the display of multiple dialog boxes as modeless.
    This is my code, can someone please post a version that would allow this box to me modeless, and any other changes i would have to make. Thanks!


    Private Sub llFormA_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles llFormA.LinkClicked
    Using NewFormA As New FormA
    Dim result = NewFormA.ShowDialog()
    End Using
    End Sub

  2. #2
    Join Date
    Oct 2012
    Posts
    4

    Re: I need help converting modal to modeless dialog boxes

    i am using visual studio 2008

  3. #3
    Join Date
    Apr 2012
    Posts
    43

    Re: I need help converting modal to modeless dialog boxes

    Use the Show method instead. Note though that it would not block so you can't wait for a return value and you can't wrap it in an Using block. Instead you handle the FormClosing event and expose the value you wish to get as a public field in your dialog Form. You capture this value in the FormClosing event.

  4. #4
    Join Date
    Oct 2012
    Posts
    4

    Re: I need help converting modal to modeless dialog boxes

    Thanks for the help, but could you be a little more specific? i have no clue as to what i am doing with VB, the closest i have come is basic c++. When i tried using the Show method, instead of the ShowDialog method, it told me it had an error code."Error 4 Expression does not produce a value."

  5. #5
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: I need help converting modal to modeless dialog boxes

    Code:
    Dim result = NewFormA.ShowDialog()
    That is because of the part in red. If you use the show method then it will not wait for the return value so there is no return value. You have to use another method to get your result if you do not use the showdialog method. Such as mentioned in the post above using the closing event of the dialog form.
    Always use [code][/code] tags when posting code.

  6. #6
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: I need help converting modal to modeless dialog boxes

    Windows Systems do not allow you to have more than one Modal dialog open, because it waits for user input. Best way would be to use the methods described by Niya

  7. #7
    Join Date
    Oct 2012
    Posts
    4

    Re: I need help converting modal to modeless dialog boxes

    Thanks for the help, i figured it out. i wasent making the changes in the correct area, and forgot to remove the using command.
    My new code is:
    Code:
    Dim NewFormA As New FormA
    NewFormA.show()
    and it works like a charm... 1 week in to learning vb and starting to make some progress

  8. #8
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: I need help converting modal to modeless dialog boxes

    That is great news!

    Please mark your thread as resolved if you feel you have recieved your answer

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured