santosh_14
asked on
Trigger only once
I want an Onchange event to call a function and trigger only once
private sub xyz_OnChange()
cocojumbo() 'This should be executed only once and in later onchange event I do not want anything to happen
End sub
Pls help
private sub xyz_OnChange()
cocojumbo() 'This should be executed only once and in later onchange event I do not want anything to happen
End sub
Pls help
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sorry that should be form level, not from...
ASKER
Thnks!!
Is there nothing in visual basic like:
set cocojumbo = dead
:-)
??
Will wait for today and if no better answer will give you the credit.
Is there nothing in visual basic like:
set cocojumbo = dead
:-)
??
Will wait for today and if no better answer will give you the credit.
ASKER
Thnks!!
Is there nothing in visual basic like:
set cocojumbo = dead
:-)
??
Will wait for today and if no better answer will give you the credit.
Is there nothing in visual basic like:
set cocojumbo = dead
:-)
??
Will wait for today and if no better answer will give you the credit.
Another option I can think off is adding a static variable to your function, which you set to true/false the first time your function runs, and test on that variable inside your function.
But I'm not entirely sure which default valeu a sttic boolean will get when you declare it.
public function CocoJumbo()
dim static HasRun as boolean
If HasRun = false Then
... ' Run code
HasRun=true
End If
end function
But I'm not entirely sure which default valeu a sttic boolean will get when you declare it.
public function CocoJumbo()
dim static HasRun as boolean
If HasRun = false Then
... ' Run code
HasRun=true
End If
end function
Otana, correct is
static HasRun as boolean
and not
dim static HasRun as boolean
>But I'm not entirely sure which default valeu a sttic boolean will get when you declare it.
Every variable has default value of it's type (Boolen->False, Integer->0, String->"") at creation time.
So static boolean var has default value False.
Otherwise your example is correct (and preferred for "triggers", since I doesn't require global variable.
santosh_14, just press F1 on Static, and you'll get an explanation. I think there is no better way of figuring out if (or how many times) function was already run than using static var.
-BozzoCage
static HasRun as boolean
and not
dim static HasRun as boolean
>But I'm not entirely sure which default valeu a sttic boolean will get when you declare it.
Every variable has default value of it's type (Boolen->False, Integer->0, String->"") at creation time.
So static boolean var has default value False.
Otherwise your example is correct (and preferred for "triggers", since I doesn't require global variable.
santosh_14, just press F1 on Static, and you'll get an explanation. I think there is no better way of figuring out if (or how many times) function was already run than using static var.
-BozzoCage
BozzoCage
You're right about the static. Sorry, I haven't used statics in quite a while, and on my age you tend to forget these things... :)
Thnx
You're right about the static. Sorry, I haven't used statics in quite a while, and on my age you tend to forget these things... :)
Thnx
static b as boolean
if b then exit sub else b = true
if b then exit sub else b = true
Like ANY Boolean variable, a STATIC Bool;ean get a default value of FALSE
Hey Experts:
Why call xyz_OnChange() twice ?
If the event initiator is a Textbox-Change for example:
Sub Text1_Change
call xyz_OnChange
TextBox1.Locked = True
end sub
But perhaps your context doesn't allow this.
:-)
Why call xyz_OnChange() twice ?
If the event initiator is a Textbox-Change for example:
Sub Text1_Change
call xyz_OnChange
TextBox1.Locked = True
end sub
But perhaps your context doesn't allow this.
:-)
ASKER
Ok! Serves the purpose