+ Reply to Thread
Results 1 to 3 of 3

Thread: using a variable in a function

  1. #1
    alvin Kuiper
    Guest

    using a variable in a function

    Hi
    i have this
    Public antal As Integer ' in decalration in the form

    then i have this in a command button
    antal = DateValue(sdage.Value) - DateValue(dage.Value)
    antaldage.Value = antal

    Its working

    Now i want to use the value of antal in a function , i run in another comman
    button

    But here it is emty Why???


    resgards

    Alvin



  2. #2
    ben
    Guest

    RE: using a variable in a function

    your variable is only public within the form, if the function is in a
    seperate form OR module then the function creates a new instance of the
    variable.
    Try sharing your variable as public in a Regular Code Module as Public, This
    will share it for the whole Project.
    Also see VBA on 'Life of Variables'
    --
    When you lose your mind, you free your life.


    "alvin Kuiper" wrote:

    > Hi
    > i have this
    > Public antal As Integer ' in decalration in the form
    >
    > then i have this in a command button
    > antal = DateValue(sdage.Value) - DateValue(dage.Value)
    > antaldage.Value = antal
    >
    > Its working
    >
    > Now i want to use the value of antal in a function , i run in another comman
    > button
    >
    > But here it is emty Why???
    >
    >
    > resgards
    >
    > Alvin
    >
    >


  3. #3
    alvin Kuiper
    Guest

    RE: using a variable in a function

    Thanks

    Alvin

    "ben" wrote:

    > your variable is only public within the form, if the function is in a
    > seperate form OR module then the function creates a new instance of the
    > variable.
    > Try sharing your variable as public in a Regular Code Module as Public, This
    > will share it for the whole Project.
    > Also see VBA on 'Life of Variables'
    > --
    > When you lose your mind, you free your life.
    >
    >
    > "alvin Kuiper" wrote:
    >
    > > Hi
    > > i have this
    > > Public antal As Integer ' in decalration in the form
    > >
    > > then i have this in a command button
    > > antal = DateValue(sdage.Value) - DateValue(dage.Value)
    > > antaldage.Value = antal
    > >
    > > Its working
    > >
    > > Now i want to use the value of antal in a function , i run in another comman
    > > button
    > >
    > > But here it is emty Why???
    > >
    > >
    > > resgards
    > >
    > > Alvin
    > >
    > >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.2.0