Share via

Modal Form Show with Using?

Peter Volz 1,295 Reputation points
2023-07-17T17:24:00.5233333+00:00

Hello everyone,

I always used this to show different modal forms from within my main form:

Dim F As New AboutForm
F.ShowDialog()

May I switch to this usage for modal forms?

Using F As New AboutForm
    F.ShowDialog()
End Using

Any idea about the difference and down sides?

Thanks :)

Developer technologies | VB
Developer technologies | C#
Developer technologies | C#

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.


1 answer

Sort by: Most helpful
  1. Jiachen Li-MSFT 34,241 Reputation points Microsoft External Staff
    2023-07-18T01:42:15.0866667+00:00

    Hi @Peter Volz ,

    A Using block has three parts: acquisition, usage, and disposal.

    The first piece of code contains only the acquisition and usage parts.

    Best Regards.

    Jiachen Li


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.