471,851 Members | 1,031 Online

# array of booleans?

Possible to have array of booleans?

Dim b1 As Boolean, b2 As Boolean, b3 As Boolean
Dim obj() As Object = {b1, b2, b3}
dim v As Object
For Each v In obj
v = True
Next

This does not work. Is it possible to have an array of
booleans that can be set in a loop as above? What would
that look like?
Nov 21 '05 #1
6 21046
This does not work. Is it possible to have an array of
booleans that can be set in a loop as above? What would
that look like?

Dim arr() As Boolean = {b1, b2, b3}
For i As Integer = 0 To arr.Length - 1
arr(i) = True
Next

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 21 '05 #2
Dim bArray(9) As Boolean

For lCnt As Integer = 0 To bArray.Length - 1
bArray(lCnt) = True
Next lCnt

Imran.

"chech" <ch***@c.com> wrote in message
news:21****************************@phx.gbl...
Possible to have array of booleans?

Dim b1 As Boolean, b2 As Boolean, b3 As Boolean
Dim obj() As Object = {b1, b2, b3}
dim v As Object
For Each v In obj
v = True
Next

This does not work. Is it possible to have an array of
booleans that can be set in a loop as above? What would
that look like?

Nov 21 '05 #3
Sub objthing()
Dim B1 As Boolean, B2 As Boolean, B3 As Boolean
Dim obj(2) As boolean
obj(0) = Bn1
obj(1) = Bn2
obj(2) = Bn3
Bn1 = False
For i As Integer = 0 To obj.Length - 1
obj(i) = True
Next
Console.WriteLine(Bn1) 'Bn1 is still False
End Sub

Is there some kind of structure I could place my booleans
into where I could use them in a loop as above? Would an
Arraylist work? Or some kind of pointer structure?
-----Original Message-----
Possible to have array of booleans?

Dim b1 As Boolean, b2 As Boolean, b3 As Boolean
Dim obj() As Object = {b1, b2, b3}
dim v As Object
For Each v In obj
v = True
Next

This does not work. Is it possible to have an array of
booleans that can be set in a loop as above? What would
that look like?
.

Nov 21 '05 #4
* "chech" <ch***@c.com> scripsit:
Possible to have array of booleans?

In addition to the other replies: Make sure you read the documentation
on value types, reference types, and boxing.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #5
In article <21****************************@phx.gbl>, chech wrote:
Possible to have array of booleans?

Dim b1 As Boolean, b2 As Boolean, b3 As Boolean
Dim obj() As Object = {b1, b2, b3}
dim v As Object
For Each v In obj
v = True
Next

This does not work. Is it possible to have an array of
booleans that can be set in a loop as above? What would
that look like?

Option Explicit On
Option Strict On

Module Module1

Sub Main()
Dim booleans() As Boolean = {True, True, True, True, True, True}

For Each b As Boolean In booleans
Console.WriteLine(b)
Next b

For i As Integer = 0 To booleans.Length - 1
booleans(i) = False
Next i

For Each b As Boolean In booleans
Console.WriteLine(b)
Next b
End Sub

End Module

--
Tom Shelton [MVP]
Nov 21 '05 #6
Chech,

Why not you can have from every object an array

Cor
Nov 21 '05 #7

### This discussion thread is closed

Replies have been disabled for this discussion.

### Similar topics

 2 posts views Thread by D. Alvarado | last post: by 5 posts views Thread by Gerrit Holl | last post: by 38 posts views Thread by VK | last post: by 3 posts views Thread by John | last post: by 1 post views Thread by Stuart | last post: by 5 posts views Thread by jar13861 | last post: by 8 posts views Thread by james | last post: by 272 posts views Thread by Peter Olcott | last post: by 32 posts views Thread by Simon L | last post: by reply views Thread by NeoPa | last post: by reply views Thread by antdb | last post: by 2 posts views Thread by guiromero | last post: by reply views Thread by Dolores Martín | last post: by 9 posts views Thread by CD Tom | last post: by 2 posts views Thread by beacampos | last post: by reply views Thread by isladogs | last post: by reply views Thread by beacampos | last post: by 1 post views Thread by DJRhino1175 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.