by
0
6
2,167
1
Top 1% !
Popular
Famous
Easy-to-find
Specified
MultiPlatform
Popularity: 8471st place
Created
Modified Oct 28, 2015
.NETFramework4.5
Architecturex86_64
Extension.vb
LanguageVB.NET

Toggle Method for Integer and Boolean Types (Extension Method)

Allow you to use Variable.Toggle() to invert the current value of a Boolean Variable. Also works with Integer type too!
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/727260/Toggle-Method-for-Integer-and-Boolean-Ty?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
Public Module Toggles <Extension()> Public Sub Toggle(ByRef Bool As Boolean) Bool = Not Bool End Sub <Extension()> Public Sub Toggle(ByRef Int As Integer) If Int > 0 Then Int = 0 Else Int = 1 End If End Sub End Module
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus