Hi Everyone
Im new here and this is my first post.
i have a vba code that i dont fully understand:
Public Function SCodeSelect(ByVal Value As Long) As Boolean
Dim bResult As Boolean
Dim ScodePattern As Long
Dim ExactMatch As Boolean
Dim IgnoreSpecial As Boolean
Dim UseOR As Boolean
'Does a bitewise AND check on value looking for the
ScodePattern = DLookup("Value1", "Variables", "Parameter='SCODE'")
ExactMatch = Val(DLookup("Value1", "Variables", "Parameter='EXACTMATCH'") & "") = 1
IgnoreSpecial = Val(DLookup("Value1", "Variables", "Parameter='IGNORESPECIAL'") & "") = 1
UseOR = Val(DLookup("Value1", "Variables", "Parameter='ANDOR'") & "") = 0
If Not UseOR Then
If ExactMatch Then
bResult = (Value = ScodePattern)
If Not bResult And IgnoreSpecial Then
bResult = ((Value - 64) = ScodePattern)
End If
Else
bResult = (Value And ScodePattern) = ScodePattern
End If
Else
'Use the OR method
'Check Each school type
'Kindy = 1
If Not bResult And (ScodePattern And 1) = 1 And (Value And 1) = 1 Then bResult = True
If Not bResult And (ScodePattern And 2) = 2 And (Value And 2) = 2 Then bResult = True
If Not bResult And (ScodePattern And 4) = 4 And (Value And 4) = 4 Then bResult = True
If Not bResult And (ScodePattern And 8) = 8 And (Value And 8) = 8 Then bResult = True
If Not bResult And (ScodePattern And 16) = 16 And (Value And 16) = 16 Then bResult = True
If Not bResult And (ScodePattern And 32) = 32 And (Value And 32) = 32 Then bResult = True
If Not bResult And (ScodePattern And 64) = 64 And (Value And 64) = 64 Then bResult = True
End If
SCodeSelect = bResult
End Function
can anyone plz help me to understand what is it doing. especially the contitions in it. maybe if someone can comment or explain what each line is doing and how is it getting to the final result which is true or false.
many thanks in advance
Im new here and this is my first post.
i have a vba code that i dont fully understand:
Public Function SCodeSelect(ByVal Value As Long) As Boolean
Dim bResult As Boolean
Dim ScodePattern As Long
Dim ExactMatch As Boolean
Dim IgnoreSpecial As Boolean
Dim UseOR As Boolean
'Does a bitewise AND check on value looking for the
ScodePattern = DLookup("Value1", "Variables", "Parameter='SCODE'")
ExactMatch = Val(DLookup("Value1", "Variables", "Parameter='EXACTMATCH'") & "") = 1
IgnoreSpecial = Val(DLookup("Value1", "Variables", "Parameter='IGNORESPECIAL'") & "") = 1
UseOR = Val(DLookup("Value1", "Variables", "Parameter='ANDOR'") & "") = 0
If Not UseOR Then
If ExactMatch Then
bResult = (Value = ScodePattern)
If Not bResult And IgnoreSpecial Then
bResult = ((Value - 64) = ScodePattern)
End If
Else
bResult = (Value And ScodePattern) = ScodePattern
End If
Else
'Use the OR method
'Check Each school type
'Kindy = 1
If Not bResult And (ScodePattern And 1) = 1 And (Value And 1) = 1 Then bResult = True
If Not bResult And (ScodePattern And 2) = 2 And (Value And 2) = 2 Then bResult = True
If Not bResult And (ScodePattern And 4) = 4 And (Value And 4) = 4 Then bResult = True
If Not bResult And (ScodePattern And 8) = 8 And (Value And 8) = 8 Then bResult = True
If Not bResult And (ScodePattern And 16) = 16 And (Value And 16) = 16 Then bResult = True
If Not bResult And (ScodePattern And 32) = 32 And (Value And 32) = 32 Then bResult = True
If Not bResult And (ScodePattern And 64) = 64 And (Value And 64) = 64 Then bResult = True
End If
SCodeSelect = bResult
End Function
can anyone plz help me to understand what is it doing. especially the contitions in it. maybe if someone can comment or explain what each line is doing and how is it getting to the final result which is true or false.
many thanks in advance