Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I exit from a function?

Tags:

i know that in vb.net you can just do Exit Sub

but i would like to know how do i exit a click event in a button?

here's my code:

private void button1_Click(object sender, EventArgs e) {     if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "")     {         //exit this event     } } 
like image 822
Alex Gordon Avatar asked Apr 12 '10 20:04

Alex Gordon


People also ask

How do you stop a function from running?

When you click Call the function button, it will execute the function. To stop the function, click Stop the function execution button.

What is exit () function in C?

The exit () function is used to break out of a loop. This function causes an immediate termination of the entire program done by the operation system. The general form of the exit() function is as follows − void exit (int code);

How do you exit a function in Python?

In python, we have an in-built quit() function which is used to exit a python program. When it encounters the quit() function in the system, it terminates the execution of the program completely.

How do you exit a function in a for loop?

The break statement exits a for or while loop completely. To skip the rest of the instructions in the loop and begin the next iteration, use a continue statement. break is not defined outside a for or while loop. To exit a function, use return .


1 Answers

Use the return statement.

MSDN Reference

like image 51
Igby Largeman Avatar answered Sep 28 '22 20:09

Igby Largeman