Ok, you could create your own custom Sub Procedure like this:
Code: Select all
Private Sub Close_Me()
Me.Close()
End Sub
The above code creates a procedure called Close_Me
When called from anywhere in the current form (or class), it will run the statement Me.Close which just closes the current form. Or completly exits the program if it's the only form in the app.
I'm still not sure what you mean by declaring it void though. This procedure will never be run unless it's called so in that case, you wouldn't really need to mark it as void.
However, a Sub Procedure never returns a value, a Funtion Procedure does though.
Functions are a tad more complicated to explain than Sub Procedures. You can declare a function with the following code:
Code: Select all
Private Function Boost(ByVal i as Integer) as Integer
Boost = i + 1
End Function
What the above code does is creates a function called Boost. Functions are sort of treated like variables in that you assign them a type. In this case we're creating the function Boost as an Integer (whole number).
The (ByVal i as Integer) means that this function is expecting an argument to be passed when the function is called and it's going to assign that argument to the variable "i" as an integer. so in this case we'd pass a number as an argument to the function.
To call this function from any procedure, we'd use the following code:
Code: Select all
Dim ReturnedBoost as Integer
ReturnedBoost = Boost(4)
Now what the above code does is first it creates an integer variable called ReturnedBoost to hold the value that will be passed back from the Boost Function.
Then it assigns the value to ReturnedBoost by calling the Boost function and passing an argument of 4.
The ending result will be that the ReturnedBoost variable will now have a value of 5 because the funtion took the argument of 4 and added 1 to it, and returned 5 when the function closed. Make Sense?
As for making a function void so it doesn't return a value, I don't think VB supports that. I could be wrong though because I'm not a programmer by profession, I just code for hobby.
Sorry for the long winded post. I hope it helped.