VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



A few things you may not have known

by john sheridan (4 Submissions)
Category: Miscellaneous
Compatability: Visual Basic 5.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (6 Votes)

Just a few things about vb that will probably be helpful to you once in a while.

Rate A few things you may not have known

Did you know you can set boolean variables to mathematical equations? For example: 



Dim blnMyBoolean As Boolean 



blnMyBoolean = (1 + 1 = 2) 



This would assign the variable a True value. On the other hand, this...



blnMyBoolean = (1 + 1 = 3) 



...would give the variable a False value. 
You can also use greater than or less than:


blnMyBoolean = (1 < 2) 'true


This is useful if you're making a math quiz program or something or you use boolean variables that test numbers.


Another good tip I know that saves time is a quick way to reverse boolean variables. For example, say you have a Command Button that Enables or Disables a timer. Instead of using an if, just do this:


Private Sub Command1_Click()

Timer1.Enabled = Not Timer1.Enabled

End Sub

You can also use this with Visible, or any other boolean variable.

I hope these two quick tips helped you. No need to vote, I just felt like uploading this.


Download this snippet    Add to My Saved Code

A few things you may not have known Comments

No comments have been posted about A few things you may not have known. Why not be the first to post a comment about A few things you may not have known.

Post your comment

Subject:
Message:
0/1000 characters