On C++ we have two different types of function which are non-returning value or void function and returning value function and what I would like to know under which condition you use either of those functions, and when do you know that you have to pass by reference(ByRef) or by value(ByVal) when you are passing parameters to those functions
There are a lot of considerations but to start with you can use one rule.
-> when you dont want to change the actual variable, you pass by value. in this case in a copy of the variable will be made in the called function and hence the original value will remain same.
-> when you want the value of the actual variable to change then you pass by reference. whatever changes you make to the value in the called function will change the value of the original variable in the calling function.
-> whenever the data passed is large, for examples structures or objects we prefer passbyref as a new copy will not be made.
well there again a lot depends on what you are trying to achieve. but i can give you some examples.
->setmethods a usually void. all that this method does is set the value of a member variable. hence you dont need to return anything.
->as i had written earlier functions where the parameters are huge we prefer to pass them by reference and make the function as void. In that case we will avoid copying of the variables.
->A return value function example would be the 'getmethods' which you would use to retrive the value of some member variable that you would have set earlier.
->and then most of the time when you want some value from the function to be used in your function you will need a return-value.
For Each ctrl As Control In Me.Controls("pnlMainPanel").Controls
If ctrl.GetType Is GetType(System.Windows.Forms.Panel) Then
For Each subCtrl As Control In ctrl.Controls
If subCtrl.GetType Is GetType(System.Windows.Forms.TextBox) Then
If subCtrl.GetType Is ...