Beja Expert Licensed User Longtime User Nov 25, 2013 #1 Hello friends, I am trying to find a way to get the sum binary result of checkbox array each time one (or more) array element is clicked. e.g. c(0) = 1, c(1) = 0, c(2) = 1, c(3) = 1... the result is 0xB Now if c(0) is clicked the result will be 0x3 and so on.. Any help appreciated.
Hello friends, I am trying to find a way to get the sum binary result of checkbox array each time one (or more) array element is clicked. e.g. c(0) = 1, c(1) = 0, c(2) = 1, c(3) = 1... the result is 0xB Now if c(0) is clicked the result will be 0x3 and so on.. Any help appreciated.
Erel B4X founder Staff member Licensed User Longtime User Nov 25, 2013 #2 Here: Code: Copy Dim c() As Boolean = Array As Boolean(True, False, True, True) Dim sum As Int For i = 1 To c.Length If c(c.Length - i) = True Then sum = sum + Bit.ShiftLeft(1, i-1) End If Next Log(sum) Log(Bit.ToHexString(sum)) Upvote 0
Here: Code: Copy Dim c() As Boolean = Array As Boolean(True, False, True, True) Dim sum As Int For i = 1 To c.Length If c(c.Length - i) = True Then sum = sum + Bit.ShiftLeft(1, i-1) End If Next Log(sum) Log(Bit.ToHexString(sum))
Beja Expert Licensed User Longtime User Nov 25, 2013 #3 Thanks so much Erel, God bless you : ) Upvote 0