when declaring variables in the main() procedure, is because you intend to use them throughout the whole program, though you can't use them in a function (unless you pass them as parameters by reference, not by value); when you declare them in a function, these variables are only useful as long as the function is running (meaning, they "die" at the end of the function); and if you declare the variables outside of any function or main() , they are Global variables, which can be used throughout all the program (meaning, main or functions).
and yes, you can get user input whereever you want to. depends on how you plan to use it what the most sensible location for it. if this is confusing to you, then just stick it in main() until you learn more about how subroutines work.
When you have a function and need to scan for 2 different numbers, should the scanf be in the function or in the main() and why?
No, you should not put the input in the function. The function's purpose is to do calculations, so keep it simple. Maybe another function for input. But keep the different processes (input, calculation, output) separate. The more you do in the function, the harder it is to debug.
I'm trying to use the numbers to do calculations in my function. I want user input to get those 2 numbers.
Then you want the input before you call the calculate function.
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 ...