Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Disabling Procedure
Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
vg19




PostPosted: Tue Apr 27, 2004 4:48 pm   Post subject: Disabling Procedure

Hi,

I am doing a vb program in which I want to disable a produre. Basically I have a Call statement. Then I have an if statement in the proceudre. What I want to do is if the If statement inside the procedure has been run once, it should disable and never be run again. I am not sure if this can be done.

Please help
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Tue Apr 27, 2004 5:00 pm   Post subject: (No subject)

sounds like a bad programming practice... but... if you must...
code:

sub myProcedure(flag as boolean)

if flag then
end '// should exit the procedure. Not sure on syntax.
end if

print "flag was false, procedure is running

end sub
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Brightguy




PostPosted: Tue Apr 27, 2004 8:22 pm   Post subject: Re: Disabling Procedure

code:
Private Sub Proc()
    Static blnDisabled As Boolean
    If blnDisabled = True Then
        Exit Sub
    End If
    If <Conditions> Then
        <Statements>
        blnDisabled = True
    End If
End Sub

Once the code in the If statement has been run, the procedure will be "disabled". You can move blnDisabled = True outside of the If statement to always disable the procedure regardless of the conditions, if that's what you wanted.
McKenzie




PostPosted: Wed Apr 28, 2004 10:19 am   Post subject: (No subject)

^ good code.
If you are looking to turn off the button that is calling the procedure use:
code:
btnWhatever.Enabled = False

at the end of the sub
Display posts from previous:   
   Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: