VBcoders Guest

Don't have an account yet? Register

Forgot Password?

A Tip to save Time

by Adam Lane (3 Submissions)
Category: Coding Standards
Compatability: Visual Basic 5.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (8 Votes)

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

Rate A Tip to save Time

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

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

Download this snippet    Add to My Saved Code

A Tip to save Time Comments

No comments have been posted about A Tip to save Time. Why not be the first to post a comment about A Tip to save Time.

Post your comment

0/1000 characters