Using OR for Value Assignments

j3rmz

New Member
Joined
Feb 1, 2016
Messages
3
Hi all,

Has anyone used OR for value assignments?

For eg.

Dim value as integer

value = 3 or 4

I can't seem to understand the logic behind this.

Thanks.
 
Hi all,

Has anyone used OR for value assignments?

For eg.

Dim value as integer

value = 3 or 4

I can't seem to understand the logic behind this.

Thanks.
value = 3
;then
For value = 3
if blah2x value = blah3x Or blah value + 1 = blah4x then blah5x
end if
Next value
 
Upvote 0
what is your source for this, please ?

Hi oldbrewer, I suppose you are requesting for my source code. Here's a sample :

Code:
Sub Test()


    Dim outputval As Integer
    Dim inputval As Integer
    Dim modval As Integer
    
    modval = 4
    
    For inputval = 1 To 10
        outputval = inputval Or modval
        Debug.Print outputval
        
        outputval = -1
    Next inputval
    


End Sub

So I'm tyring to figure the logic behind this part : "outputval = inputval Or modval".

The For loop is for me trying to figure out a pattern, to which I have none for the moment. Haha
 
Upvote 0
[h=2]Or Operator Example[/h]This example uses the Or operator to perform logical disjunction on two expressions.
<code>Dim A, B, C, D, MyCheck
A = 10: B = 8: C = 6: D = Null ' Initialize variables.
MyCheck = A > B Or B > C ' Returns True.
MyCheck = B > A Or B > C ' Returns True.
MyCheck = A > B Or B > D ' Returns True.
MyCheck = B > D Or B > A ' Returns Null.
MyCheck = A Or B ' Returns 10 (bitwise comparison).
</code>
 
Upvote 0
[TABLE="width: 256"]
<colgroup><col width="64" span="4" style="width:48pt"> </colgroup><tbody>[TR]
[TD="width: 64"][/TD]
[TD="width: 64"][/TD]
[TD="width: 64"][/TD]
[TD="width: 64"][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD="colspan: 2"]modval = 4[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD="colspan: 3"] outputval = 2 Or modval[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="colspan: 3"] Cells(1, 1) = outputval[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="colspan: 2"] End Sub[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]returns 6[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD="colspan: 2"]modval = 4[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD="colspan: 3"] outputval = 3 Or modval[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="colspan: 3"] Cells(1, 1) = outputval[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="colspan: 2"] End Sub[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]returns 7[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD="colspan: 2"]modval = 4[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD="colspan: 3"] outputval = 4 Or modval[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="colspan: 3"] Cells(1, 1) = outputval[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="colspan: 2"] End Sub[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]returns 4[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD="colspan: 2"]modval = 4[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD="colspan: 3"] outputval = 5 Or modval[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="colspan: 3"] Cells(1, 1) = outputval[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="colspan: 2"] End Sub[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]returns 5[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD="colspan: 2"]modval = 4[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD="colspan: 3"] outputval = 6 Or modval[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="colspan: 3"] Cells(1, 1) = outputval[/TD]
[/TR]
[TR]
[TD][/TD]
[TD="colspan: 2"] End Sub[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]returns 6[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0

Forum statistics

Threads
1,226,894
Messages
6,193,543
Members
453,807
Latest member
PKruger

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top