static as integer

sey

New Member
Joined
Apr 28, 2011
Messages
35
Code:
 Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim i As Integer
        Static h As Integer
        
        '***********handles collision with a rock, tree, skier********
        If contact = "hit" Then h = h + 1
        If h = 15 Then
            imgOuch.Visible = False
        End If
        If h > 14 Then
            contact = ""
            h = 0
            imgOuch.Visible = False
        End If

For what does "static as integer" stand for. And how can I use "static"? Whats the difference between "dim" and "static"?
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
How do I get the variable to be shared to a function (without overtly passing it)?

for example, I'm using "i" in a loop in my sub and I call a function that I want to also use the same "i".
 
Upvote 0
Why don't you want to pass it? That's the best way, as a rule.
 
Upvote 0
If they are both in the same module, declare the variable at module level only.
 
Upvote 0
how do I do that? Like this? (really lame example)
Code:
dim i as integer
sub something()
    i = 1
    msgbox (lame) 
end sub
function lame() as string
    lame = i + 5
end function
 
Upvote 0

Forum statistics

Threads
1,224,562
Messages
6,179,526
Members
452,923
Latest member
JackiG

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top