Results 1 to 4 of 4
  1. #1
    Join Date
    May 2004
    Posts
    18

    Unanswered: function in access.

    Hi all..
    I need to build a function with 2 variable

    I knwo for function with 1 varible, i can do this

    function mynumber(byval a as integer)
    msgbox(a)
    end function

    this will give me a message box for the value i enter
    like
    mynumber(5) = 5

    What I have a problem is with 2 or more variable

    for example....

    function mynumber(byval a as integer, byval b as integer)
    dim x as integer
    x = a + b
    msgbox(x)
    end function

    This one does not work

    Please tell me how to fix this ....

    Thank you all in advance

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    function mynumber(a as integer, b as integer)

    Note that since you're passing integers, you techincally don't even need the byval at all.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    Jun 2004
    Posts
    96
    is there any error message? or what is the result?

    Cyherus

  4. #4
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,424
    Provided Answers: 8
    try this
    for example....

    From this
    function mynumber(byval a as integer, byval b as integer)
    dim x as integer
    x = a + b
    msgbox(x)
    end function


    to


    function mynumber(a as integer,b as integer)
    dim x as integer
    mynumber = a + b
    msgbox(mynumber)
    end function


    newanswer = mynumber(2,5)

    msgbox will say 7
    and the newanswer will have 7 as a value
    hope this help

    See clear as mud


    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB based on my own environment: vb6 sp5
    ASP based on my own environment: 5.6
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    MYLE
    YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.

Posting Permissions

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