2

I am facing one small problem please help me.

sub vari()
dim b as integer
dim c as integer
b=6
c=8
end sub

now i want to use b and c in another function .

sub calculate()
dim a as integer
a = c+b
end sub

I am getting error here

Community
  • 1
  • 1
M_S_SAJJAN
  • 167
  • 3
  • 5
  • 16

1 Answers1

8

You want to use the proper scope for your variables. If you want for b and c to be accessible to both vari() and calculate() you need to declare them globally, like so:

Public b As Integer
Public c As Integer
sub vari()
....
Asad Saeeduddin
  • 45,116
  • 6
  • 87
  • 135