A Tip to save Time
![Visual Basic 6, or VB Classic Visual Basic 6, or VB Classic](https://www.fortypoundhead.com//assets/img/icons/v7/vb6.png)
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
Loading Comments ...
Comments
No comments have been added for this post.
You must be logged in to make a comment.