Re: Exiting a Subroutine
- From: "Clint (cmueller@xxxxxxxxxxxxx)" <cjmueller@xxxxxxxxx>
- Date: 12 Apr 2005 13:51:13 -0700
Hey,
You can use the return keyword for this:
if (this.txtFirstName.Text == "")
{
MessageBox.Show("First Name is required");
this.txtFirstName.Focus();
return;
}
Hope that helps,
Clint
OutdoorGuy wrote:
> Greetings,
>
> I'm still relatively new to C# and was wondering if there was a way
to
> exit a subroutine (such as "Exit Sub" in VB)? I have the code below
> which performs validations. If the user fails to enter in a First
name,
> then I want to set the focus to the control on the form and then exit
> the subroutine. Any ideas?
>
> private void btnSubmit_Click(object sender, System.EventArgs e)
> {
> ..
>
> if (this.txtFirstName.Text == "")
> {
> MessageBox.Show("First Name is required");
> this.txtFirstName.Focus();
> // I then want to exit the subroutine.
> }
> if (Lastname == "")
> {
> ..
>
> Thanks in advance!
>
>
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
.
- Follow-Ups:
- Re: Exiting a Subroutine
- From: OutdoorGuy
- Re: Exiting a Subroutine
- References:
- Exiting a Subroutine
- From: OutdoorGuy
- Exiting a Subroutine
- Prev by Date: Re: Exiting a Subroutine
- Next by Date: Problem with Event Log event triggers
- Previous by thread: Re: Exiting a Subroutine
- Next by thread: Re: Exiting a Subroutine
- Index(es):
Relevant Pages
|