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
  1. Home
  2. General Programming
  3. Visual Basic
  4. AddressOf with arguments

AddressOf with arguments

Scheduled Pinned Locked Moved Visual Basic
helpquestion
6 Posts 3 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.
  • A Offline
    A Offline
    Amer Rehman 0
    wrote on last edited by
    #1

    Hi When I use the "AddressOf" operand to call a procidure that requires some arguments, error occurs. How can I handle this problem. Error is "AddressOf operand must be the name of a method, no parentheses are required. Code snippet is below. Dim trThread As New Thread(AddressOf DoSomething(Arguments)) Sub DoSomething(Arguments) 'do something whatever it be End Sub Thanks reman

    D C 2 Replies Last reply
    0
    • A Amer Rehman 0

      Hi When I use the "AddressOf" operand to call a procidure that requires some arguments, error occurs. How can I handle this problem. Error is "AddressOf operand must be the name of a method, no parentheses are required. Code snippet is below. Dim trThread As New Thread(AddressOf DoSomething(Arguments)) Sub DoSomething(Arguments) 'do something whatever it be End Sub Thanks reman

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

      You can't do that. AddressOf returns exactly that, the address of a method. Your not actually calling the method, so passing parameters is pointless. Which version of VB.NET are you using??

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

      1 Reply Last reply
      0
      • A Amer Rehman 0

        Hi When I use the "AddressOf" operand to call a procidure that requires some arguments, error occurs. How can I handle this problem. Error is "AddressOf operand must be the name of a method, no parentheses are required. Code snippet is below. Dim trThread As New Thread(AddressOf DoSomething(Arguments)) Sub DoSomething(Arguments) 'do something whatever it be End Sub Thanks reman

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

        On assumes you should just provide DoSomething and not worry about the arguments. You can only start a thread that takes no arguments, or a single argument, of type object, AFAIK.

        Christian Graus - Microsoft MVP - C++ "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 )

        D 1 Reply Last reply
        0
        • C Christian Graus

          On assumes you should just provide DoSomething and not worry about the arguments. You can only start a thread that takes no arguments, or a single argument, of type object, AFAIK.

          Christian Graus - Microsoft MVP - C++ "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 )

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

          Christian Graus wrote:

          or a single argument, of type object, AFAIK.

          You are correct sir. Now, IIRC, that's only in .NET 2.0 and above. I think .NET 1.1- couldn't take any arguments at all and had to pick up any arguments from a third party object visible to the method being launched.

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

          C 1 Reply Last reply
          0
          • D Dave Kreskowiak

            Christian Graus wrote:

            or a single argument, of type object, AFAIK.

            You are correct sir. Now, IIRC, that's only in .NET 2.0 and above. I think .NET 1.1- couldn't take any arguments at all and had to pick up any arguments from a third party object visible to the method being launched.

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

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

            No, I think I wrote .NET 1.1 code that multithreaded with a parameter.

            Christian Graus - Microsoft MVP - C++ "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 )

            D 1 Reply Last reply
            0
            • C Christian Graus

              No, I think I wrote .NET 1.1 code that multithreaded with a parameter.

              Christian Graus - Microsoft MVP - C++ "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 )

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

              Really?? I haven't done any threading in quite a while. I've forgotten a bunch... I thought ThreadStart didn't take an argument, but the 2.0 ParameterizedThreadStart took an Object. Hmmm... where's my MSDN... :confused:

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

              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