Results 1 to 3 of 3

Thread: quick qustion

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2001
    Posts
    10

    quick qustion

    how do u pass a variable by adress to a function?

  2. #2
    Junior Member
    Join Date
    Jan 2002
    Posts
    22
    By default variables are passed by reference. You can also include the ByRef keyword in the function template.
    put a button and a textbox in a form.

    In declaration:
    private x as integer


    private function getvar( ByRef t as integer) as integer
    dim hold as integer
    hold=t
    t=50
    getvar=hold
    end function

    Command1_click()
    dim a as integer
    x=10
    a=getvar(x)
    Text1.text="xold=" & a & " " & "xnew=" & x
    end sub

  3. #3
    PWNettle
    Guest
    Um, not exactly sure what you mean. In VB you can pass values two ways, ByVal or ByRef. I'm thinking you want to pass ByRef. For ex;

    Sub Foo(ByRef varSomeVar As Variant)

    Variables passed ByRef can be modified the the routine you're passing them to (which I guess would mean you are passing by memory address).

    VB passes ByRef by default but you can specify it to be explicit.

    Paul

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