using a variable in a function

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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'
 
Thanks

Alvin

ben said:
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'
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top