Results 1 to 6 of 6

Thread: VB Equivilent in C#

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2005
    Posts
    258

    VB Equivilent in C#

    What is the equivilent of "Exit Sub" in C#?

    Also, what statement will cause the form to close if a condition isnt met? For example, I want to close a form if someoneclicks Cancel to open a file.

    Thanks for all your patience!
    Currently Using: VS 2005 Professional

  2. #2
    Fanatic Member
    Join Date
    Jan 2006
    Posts
    710

    Re: VB Equivilent in C#

    "return"

    To close a form, just use "this.Close()"
    David Anton
    Convert between VB, C#, C++, & Java
    www.tangiblesoftwaresolutions.com

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    May 2005
    Posts
    258

    Re: VB Equivilent in C#

    I did that but it still went through the form_load funciton anyways. Unless that will not work in form_load?
    Currently Using: VS 2005 Professional

  4. #4
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: VB Equivilent in C#

    It would be of help if you could post the code you are currently using...
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: VB Equivilent in C#

    Once you call Show on a Form the Load event is raised and the Load event handler is executed. Even if you call Close within the Load event handler the the method will continue until it reaches and exit point and the form will be displayed, but only for a moment. If you want to do something first that will affect whether a form is displayed then do so before calling Show. Don't call Show if you don't, or might not, want to Show it.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  6. #6
    Frenzied Member Phill64's Avatar
    Join Date
    Jul 2005
    Location
    Queensland, Australia
    Posts
    1,201

    Re: VB Equivilent in C#

    you could make youself a new public function, like .TryShow on your form, which will test whatever it is you are etsting for, and from there it either calls .Show or doesnt.

    this will save you having to modify your other code, and allow you to re-use it.

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