Functions.

  • Thread starter Thread starter Nocturnal
  • Start date Start date
N

Nocturnal

What is a function, how do you pass something to a function? Can anyone
elaborate on this for me? I'm rather new to programming.
 
A subroutine and a function are practically the same thing. The only
difference is that a function returns something.

Example:

Public Sub AddNumbersSubroutine(x as integer, y as integer)

Debug.WriteLine(x + y)

End Sub

Public Function AddNumbersFunction(x as integer, y as integer) as integer

Return x + y

End Function

Then, in another part of your program, you can either say:

Call AddNumbersSubroutine(10, 32)

Or, you can say:

Dim myValue as Integer
myValue = AddNumbersFunction(10, 32)

Hope this helps.

-Jason
 
How do you know what to type between the ()? That is what perplexes the
crap out of me. I get confused. It's like ok say you have function()...
would you just type whatever the function may have in between the ()? Like
function(return_this)?
 
Optic,

That helped me tremendously. I didn't realize that you were going to USE
them later on in the program.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top