Click to See Complete Forum and Search --> : Declaring a method...


YourSurrogateGod
March 19th, 2005, 10:52 PM
Stupid question (can't find the answer in the book :rolleyes: .) When strict is on, what do you put at the end of a method declaration in order to make it compile when you don't want to return anything (in C/C++ you have void)?
Option Strict On
Option Explicit On

Module Module1
Sub Main()

End Sub

Function Addition(ByVal n As Integer, ByRef result As Integer) As Nothing

End Function
End Module

jhammer
March 20th, 2005, 12:41 AM
Instead of function you use Sub:

Public Sub YourSub(param1 as Type1, param2 as Type2)

End Sub

You can see that Sub do not return any type.

YourSurrogateGod
March 20th, 2005, 01:27 AM
So I take it that what I wanted to do initially (given that Strict is on) with a Function is impossible? Just curious...

DSJ
March 21st, 2005, 08:08 AM
Yes. A function returns a value, a Sub does not.