Results 1 to 4 of 4

Thread: Calling on Sub... Why doesn't it work ? =(

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 1999
    Posts
    12

    Post

    To tell the thruth, I'm almost ashamed to ask such a question, but I haven't have much of a choice...
    I want to know how to call a Sub from an object.
    I've got no trouble calling on functions, yet when I call on a Sub,
    IE : Generator.GenerateVariables(Param1, Param2)

    I get an error :" = Excepted"
    Does that mean VB believe it isn't a Sub, rather a property ??

    I can't figure this out...

  2. #2
    Hyperactive Member
    Join Date
    Sep 1999
    Location
    Leeds, UK
    Posts
    287

    Post

    Its because the sub you are calling contains (). (make sure inside here is empty).

    for example:
    Generator.GenerateVariables(Param1, Param2)

    should be:
    Generator.GenerateVariables()

    Don't ask me why


    [This message has been edited by rino_2 (edited 01-30-2000).]

  3. #3
    Guest

    Post

    why does that happen? even if it isn't supposed to return something it still asks for an = sign. call it like this:
    sub num1, num2
    instead of
    sub(num1,num2)
    that should solve your problem

  4. #4
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    Actually, it's because when you put parenthesies around your Parameters VB expects you to return a Value which it then has to assign, hence it tells you "=" is expected.

    2 Ways to avoid this,

    1) Use Call, ie. Call Generator.GenerateVariables(Param1, Param2)

    or..

    2) Remove the Parenthesies, ie. Generator.GenerateVariables Param1, Param2

    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]


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