CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2004
    Location
    In the back seat of New Horizons.
    Posts
    1,238

    Declaring a method...

    Stupid question (can't find the answer in the book .) 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)?
    Code:
    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
    Here are the rules, you must obey them or the gender bender will get you.

    And if you ever think of posting without code-tags, the evil monkey will come after you.

  2. #2
    Join Date
    Feb 2005
    Location
    Israel
    Posts
    1,475

    Re: Declaring a method...

    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.

  3. #3
    Join Date
    Apr 2004
    Location
    In the back seat of New Horizons.
    Posts
    1,238

    Re: Declaring a method...

    So I take it that what I wanted to do initially (given that Strict is on) with a Function is impossible? Just curious...
    Here are the rules, you must obey them or the gender bender will get you.

    And if you ever think of posting without code-tags, the evil monkey will come after you.

  4. #4
    Join Date
    Jun 2001
    Location
    MO, USA
    Posts
    2,868

    Re: Declaring a method...

    Yes. A function returns a value, a Sub does not.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured