473,473 Members | 2,031 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 21987
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: D. Alvarado | last post by:
Hello, I have an array that contains numbers. Each element in the array is guaranteed to be unique. Let's say I have another variable which I know for certain is in the array, but I don't know...
5
by: Gerrit Holl | last post by:
Hi, is it proper to compare booleans? It is possible, of course, because they're compatible with numbers, but booleans aren't truly numbers. I'm tempted to write: return cmp(self.extends,...
38
by: VK | last post by:
Hello, In my object I have getDirectory() method which returns 2-dimentional array (or an imitation of 2-dimentional array using two JavaScript objects with auto-handled length property - please...
3
by: John | last post by:
Hi, I need to build a BAUDOT lookup table for an encoder. I see to use a char as the index 'A' or 'B' and get back an array of booleans (five elements long). Baudot = {00011} Baudot =...
1
by: Stuart | last post by:
I am converting a VB6 App. In the VB6 app, I have a Type structure of about 30 elements (mixture of booleans, integers, strings and some doubles), in an array of say 20 to 100+ records. The...
5
by: jar13861 | last post by:
I'm confused on how to write a random array that will only generate 9 different numbers from 1-9. Here is what I have, but its only writing one number.... holder = new Array ( 9 ); var flag =...
8
by: james | last post by:
Hi, Just looking here: http://msdn2.microsoft.com/en-us/library/9b9dty7d.aspx I can't quite see what I want to do. I want an array of Booleans of length 102, all initially "false". I have this...
272
by: Peter Olcott | last post by:
http://groups.google.com/group/comp.lang.c++/msg/a9092f0f6c9bf13a I think that the operator() member function does not work correctly, does anyone else know how to make a template for making two...
32
by: Simon L | last post by:
BOOL bMyarray; memset(bMyArray , 0xFF, sizeof(BOOL) * 1000); clean & quick until someone else's code found I was returning -1 to mean true Because my BOOL is 4 bytes long, TRUE in memory...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.