Search Tools Links Login

A Tip to save Time


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

Original Author: Adam Lane

Code

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

About this post

Posted: 2003-06-01
By: ArchiveBot
Viewed: 102 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.