473,396 Members | 1,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Text representations of Booleans

This question is just for my education as there are some simple and
obvious workarounds, but...

I have an array of Booleans that I need to export to a text file.
Currently the Boolean values are appearing in the text file as the
text strings True/False, but I need them as the integers 1 and 0 (for
input to another program that only recognises Booleans in integer
form). Have I overlooked a suitable Boolean method (eg if there were a
Boolean.ToInteger) that can do this at one stroke?

Thanks
JGD
Nov 21 '05 #1
1 1060
John Dann wrote:
I have an array of Booleans that I need to export to a text file.
Currently the Boolean values are appearing in the text file as the
text strings True/False, but I need them as the integers 1 and 0


Here are two suggestions.

You can use CInt() to convert the boolean to a number -- but it will use -1
and 0 for True and False. You can make this into 1 and 0 by using the Abs()
function:

MsgBox(Math.Abs(CInt(yourbool))

Alternatively you could use IIf to do anything you want:

MsgBox(CStr(IIf(yourbool, "1", "0")))

--

(O) e n o n e
Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

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,...
4
by: Dr. Know | last post by:
I seem to be having an unresolvable problem with an ASP page (darned typeless scripting engines) and JET datatypes. Don't ask why we are using JET, let's just say it has something to do with...
8
by: Rade | last post by:
Following a discussion on another thread here... I have tried to understand what is actually standardized in C++ regarding the representing of integers (signed and unsigned) and their conversions....
5
by: Christopher Benson-Manica | last post by:
I have a situation where I have many (more than 32) boolean flags: var foo=true; var bar=false; var baz=false; // etc. At various points in the script, these flags may be set or unset....
6
by: chech | last post by:
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. ...
10
by: pemo | last post by:
As far as I understand it, a trap representation means something like - an uninitialised automatic variable might /implicitly/ hold a bit-pattern that, if read, *might* cause a 'trap' (I'm not...
4
by: shankwheat | last post by:
I'm passing a string like 'Div3,Div4' to use as options in a selectbox but I need the text the user sees in the box different from the values. My code populates the values in the selectbox...
8
by: mathieu | last post by:
Hi, I was trying to make an entry in a std::map be stored more efficiently. The struct contained 3 booleans discribing it's property, so I am trying to make it as compact as possible. Using a...
2
by: SiJP | last post by:
Hi, My vb.net project sends an Input object to a webservice and retrieves a Results object. The webservice is maintained by a third party, and is pretty huge. I am using the following...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...
0
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,...

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.