473,605 Members | 2,095 Online
Bytes | Software Development & Data Engineering Community
+ 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 22043
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.WriteLi ne(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.WriteLi ne(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.WriteLi ne(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
4313
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 the position. What's the quickest way for removing that element? I know I could just use a foreach, but I'm sure one of the experts out there has a better way. Thanks, - Dave
5
1842
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, other.extends) instead of
38
5178
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 let's us do not go into an "each dot over i" clarification discussion now - however you want to call - you call it ;-) array contains records of all files in the current dir. array contains records of all subs in the current dir
3
2403
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 = {11001} Can someone give me a pointer on how to build this as a static lookup
1
1065
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 size of the array doesn't change that frequently, so the speed of inserting and removing records is not that important. However, the speed of finding, and read/writing of the elements is very import. Needs to be thread safe too.
5
2073
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 = true; var rannum = Math.floor( 1 + Math.random() * 9 ); for (var j = 0; j < 9; j++) {
8
19709
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 so far: public bool Monitors = new bool; but if I add on the end of that : {false}, I get a compile error of "Invalid
272
13989
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 dimensional arrays from std::vectors ??? I want to use normal Array Syntax.
32
11408
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 works out as 01 00 00 00 which is a right pain. Doing it in a for loop is 10 x slower btw.
0
7938
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8427
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8078
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6752
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5452
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3914
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3962
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2441
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1548
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.