Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,861 questions

51,782 answers

573 users

How to use a bitwise operator to pass multiple Integer values to a function for VB.NET

1 Answer

0 votes
Imports System

Public Class Program
    Const ONE As Integer = &H01
    Const TWO As Integer = &H02
    Const THREE As Integer = &H04
    Const FOUR As Integer = &H08

    Public Shared Sub MultiValueExample(ByVal values As Integer)
        If (values And ONE) = ONE Then
            Console.WriteLine("ONE")
        End If

        If (values And TWO) = TWO Then
            Console.WriteLine("TWO")
        End If

        If (values And THREE) = THREE Then
            Console.WriteLine("THREE")
        End If

        If (values And FOUR) = FOUR Then
            Console.WriteLine("FOUR")
        End If
    End Sub

	Public Shared Sub Main()
        MultiValueExample(ONE Or THREE Or FOUR)
    End Sub
End Class

 
  
' run:
'
' ONE
' THREE
' FOUR
'

 



answered Jan 14, 2025 by avibootz
...