AngelicGuardian
Village Idiot
- Local time
- Today, 23:12
- Joined
- Apr 7, 2003
- Messages
- 43
I need a way of retrieving multiple booleans from one integer
and I wasn't sure if there was a better way then this:
and I wasn't sure if there was a better way then this:
Code:
Dim totalOfOptions As Integer
Dim currentOption As Integer
Dim currentAmount As Integer
Dim currentTotal As Integer
Dim totalOptions As Integer
While currentTotal <= totalOfOptions
currentOption = currentOption + 1
If (currentAmount = 0) Then
currentAmount = currentAmount + 1
Else
currentAmount = currentAmount * 2
End If
currentTotal = currentTotal + currentAmount
Wend
Dim Options(0 To 255) As Boolean
totalOptions = currentOption
While currentOption > 0
If (currentAmount <= totalOfOptions) Then
Options(currentOption) = True
totalOfOptions = totalOfOptions - currentAmount
Else
Options(currentOption) = False
End If
currentAmount = currentAmount / 2
currentOption = currentOption - 1
Wend
Last edited: