Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. How to create a function that does not return a value?

How to create a function that does not return a value?

Scheduled Pinned Locked Moved Visual Basic
helptutorialquestion
9 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Vivek Narayanan
    wrote on last edited by
    #1

    i want to create a function that utilizes a String and does just about the same thing as a Sub,but does not return a value ,can any one help me out?

    C S 2 Replies Last reply
    0
    • V Vivek Narayanan

      i want to create a function that utilizes a String and does just about the same thing as a Sub,but does not return a value ,can any one help me out?

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      A function returns a value, a sub does not. This is another VB disaster, IMO. But, the void return type is a sub. If it's a function, it returns something. Otherwise, there's no difference, AFAIK.

      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

      1 Reply Last reply
      0
      • V Vivek Narayanan

        i want to create a function that utilizes a String and does just about the same thing as a Sub,but does not return a value ,can any one help me out?

        S Offline
        S Offline
        Steven J Jowett
        wrote on last edited by
        #3

        A function that does the same as a sub ??? I would have thought the solution to be obvious; use a sub

        Steve Jowett

        V 1 Reply Last reply
        0
        • S Steven J Jowett

          A function that does the same as a sub ??? I would have thought the solution to be obvious; use a sub

          Steve Jowett

          V Offline
          V Offline
          Vivek Narayanan
          wrote on last edited by
          #4

          I meant a function that does the same as a sub ,but like all functions do,utilizes an Object or a Component but does not return any value

          V 1 Reply Last reply
          0
          • V Vivek Narayanan

            I meant a function that does the same as a sub ,but like all functions do,utilizes an Object or a Component but does not return any value

            V Offline
            V Offline
            Vivek Narayanan
            wrote on last edited by
            #5

            Let me make it clear,its something like this Function str() as String 'code related with str ,which does something to the form,just like code in an event sub RETURN 'I've got nothing to return End Function Say if i choose null as the return value,will the code above it be processed,irrespective of the fact that the function will always return null

            S D 2 Replies Last reply
            0
            • V Vivek Narayanan

              Let me make it clear,its something like this Function str() as String 'code related with str ,which does something to the form,just like code in an event sub RETURN 'I've got nothing to return End Function Say if i choose null as the return value,will the code above it be processed,irrespective of the fact that the function will always return null

              S Offline
              S Offline
              Steven J Jowett
              wrote on last edited by
              #6

              You could do this :- Function str() as string 'your code here Return Nothing End Function but surely that is the same as :- Sub str() 'your code here End Sub Or is it you what to provide an object for the "function" to work with and change, in which case :- Sub str(ByRef myObject as Object) 'do something to myObject End Sub This would receive the memory address the the object and change it directly, without the need to passing back the result

              Steve Jowett ------------------------- Sometimes a man who deserves to be looked down upon because he is a fool, is only despised only because he is an 'I.T. Consultant'

              V 1 Reply Last reply
              0
              • V Vivek Narayanan

                Let me make it clear,its something like this Function str() as String 'code related with str ,which does something to the form,just like code in an event sub RETURN 'I've got nothing to return End Function Say if i choose null as the return value,will the code above it be processed,irrespective of the fact that the function will always return null

                D Offline
                D Offline
                Dave Kreskowiak
                wrote on last edited by
                #7

                What you're talking about is still a Sub.

                Private Sub SetupDataGridView()
                     ' Code to setup your DGV goes here.
                End Sub
                

                Seriously, pickup a book on VB.NET for Beginners. This is really basic stuff you're asking about.

                A guide to posting questions on CodeProject[^]
                Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                     2006, 2007

                1 Reply Last reply
                0
                • S Steven J Jowett

                  You could do this :- Function str() as string 'your code here Return Nothing End Function but surely that is the same as :- Sub str() 'your code here End Sub Or is it you what to provide an object for the "function" to work with and change, in which case :- Sub str(ByRef myObject as Object) 'do something to myObject End Sub This would receive the memory address the the object and change it directly, without the need to passing back the result

                  Steve Jowett ------------------------- Sometimes a man who deserves to be looked down upon because he is a fool, is only despised only because he is an 'I.T. Consultant'

                  V Offline
                  V Offline
                  Vivek Narayanan
                  wrote on last edited by
                  #8

                  thanks,i might appear like a newbie,but i'm not,its just that i learned everything by trial and error and my knowledge of the vb lang is here and there

                  C 1 Reply Last reply
                  0
                  • V Vivek Narayanan

                    thanks,i might appear like a newbie,but i'm not,its just that i learned everything by trial and error and my knowledge of the vb lang is here and there

                    C Offline
                    C Offline
                    Colin Angus Mackay
                    wrote on last edited by
                    #9

                    Vivek Narayanan wrote:

                    i learned everything by trial and error and my knowledge of the vb lang is here and there

                    I suggest you buy a book and fill in the gaps.


                    Upcoming events: * Glasgow: SQL Server 2005 - XML and XML Query Plans, Mock Objects, SQL Server Reporting Services... Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton My website

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups