article

A Tip to save Time

Email
Submitted on: 1/29/2015 1:00:00 PM
By: Adam Lane (from psc cd)  
Level: Beginner
User Rating: By 8 Users
Compatibility: VB 5.0, VB 6.0
Views: 659
 
     This is a tip that will save many of you VB Programmers a lot of time. It is a piece of code that allows the user in one line of code to create a toggle system. Enjoy

 
				

A Tip to Save Time
by Adam Lane

Say you want to make a toggle system, eg: You have a form and in that form you have a Picture Box and a Command Button and you want to make a project where whenever you click on the Command Button, the Picture Box will go invisible/visible (opposite to what it's current state is). Instead of having to write this boring code:


Private Sub Command1_Click()
If Picture1.Visible = True Then
Picture1.Visible = False
ElseIf Picture1.Visible = False Then
Picture1.Visible = True
End If
End Sub

You can Replace it with this easy code:


Private Sub Command1_Click() Picture1.Visible = Not Picture1.Visible
End Sub

Now, I know that code is simple and the majority of you probably already knew it. But I know that there would be many people in the VB World that didn't.

- Adam Lane


Other 2 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Beginner category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)
 

To post feedback, first please login.