473,467 Members | 1,436 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

converting from AnsiString to integer

JNY
Hi,

I'm using a GUI Edit box to allow the user to enter a number. This
data is stored as an AnsiString. I need it in Integer format, but
cannot convert between the two. I found AnsiString::ToINT in the help
file, and have tried to impliment it thus:

int myValue = AnsiString::ToInt(Edit1 -> Text);

This doesn't work. Edit1 is the Edit Box, and Text, is an attribute
of said box. I am using Borland Builder5. This is the only GUI
compiler which I've used, so I'm not sure if this syntax is common to
others.

Can anyone help?

Cheers
JNY
Jul 22 '05 #1
5 7928
JNY wrote:
I'm using a GUI Edit box to allow the user to enter a number. This
data is stored as an AnsiString. I need it in Integer format, but
cannot convert between the two. I found AnsiString::ToINT in the help
file, and have tried to impliment it thus:

int myValue = AnsiString::ToInt(Edit1 -> Text);

This doesn't work. Edit1 is the Edit Box, and Text, is an attribute
of said box. I am using Borland Builder5. This is the only GUI
compiler which I've used, so I'm not sure if this syntax is common to
others.
No, it's not common. There is no GUI in C++, it's all platform-
and compiler-specific.

Can anyone help?


Somebody in one of borland.public.cppbuilder.* NGs certainly can.

V
Jul 22 '05 #2
A fine GUI programming capability for C++, which compiles for UNIX,
LINUX, Macintosh and windows is TROLLTECH Qt. Just Google to their web
site. It has a complete set of edit boxes and other I/O features that
you may find useful. There are commercial=$ and free versions of Qt,
depending on your needs.

LFP

Victor Bazarov wrote:
JNY wrote:
I'm using a GUI Edit box to allow the user to enter a number. This
data is stored as an AnsiString. I need it in Integer format, but
cannot convert between the two. I found AnsiString::ToINT in the help
file, and have tried to impliment it thus:

int myValue = AnsiString::ToInt(Edit1 -> Text);

This doesn't work. Edit1 is the Edit Box, and Text, is an attribute
of said box. I am using Borland Builder5. This is the only GUI
compiler which I've used, so I'm not sure if this syntax is common to
others.

No, it's not common. There is no GUI in C++, it's all platform-
and compiler-specific.

Can anyone help?

Somebody in one of borland.public.cppbuilder.* NGs certainly can.

V

Jul 22 '05 #3
int myValue = Edit1->Text.ToInt();

Jul 22 '05 #4

"JNY" <jn**@hotmail.com> wrote in message
news:91************************@posting.google.com ...
Hi,

I'm using a GUI Edit box to allow the user to enter a number. This
data is stored as an AnsiString. I need it in Integer format, but
cannot convert between the two. I found AnsiString::ToINT in the help
file, and have tried to impliment it thus:

int myValue = AnsiString::ToInt(Edit1 -> Text);


Documentation is a good thing. :-) Look up the definition of ToInt() (in
the online Help, or your manual, or on a newsgroup or website devoted to the
compiler you're using). My guess is that it takes no parameters at all, and
that it returns an int. Also, I'm guessing that the Text member of Edit1's
class is an AnsiString? If my guesses are correct (check the manual!), that
call should be

int MyValue = Edit1->Text.ToInt();

-Howard
Jul 22 '05 #5

"Howard" <al*****@hotmail.com> wrote in message news:fzzDd.3035>
Documentation is a good thing. :-) Look up the definition of ToInt() (in
the online Help, or your manual, or on a newsgroup or website devoted to the compiler you're using). My guess is that it takes no parameters at all, and

newsgroups.borland.com
Look for groups with VCL in the title.
that it returns an int. Also, I'm guessing that the Text member of Edit1's class is an AnsiString? If my guesses are correct (check the manual!), that call should be

int MyValue = Edit1->Text.ToInt();


That should be wrapped with a try/catch as ToInt() throws
an EConvertError if it can't convert the string. See also
ToIntDef().
Jul 22 '05 #6

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

Similar topics

2
by: Mendon?a | last post by:
I cant seem to find on borland help files anything about AnsiString to char conversion. Just the opposite. Can u help me?
3
by: Nikola | last post by:
Hi all, I have a problem converting datetime to integer (and than back to datetime). Depending whether the time is AM or PM, same date is converted to two different integer representations,...
9
by: Franz Seidl | last post by:
Hello, how can i convert a AnsiString to double? I'm using C++ Builder 5 from Borland... Greets, Franz --
2
by: Asbjørn Ulsberg | last post by:
Hi. I'm trying to convert Brady Hegberg's great RTF2HTML VB 6.0 module to C#. I've managed to convert the VB code to VB.NET, which gave me the following code: Option Strict On Option...
116
by: Dilip | last post by:
Recently in our code, I ran into a situation where were stuffing a float inside a double. The precision was extended automatically because of that. To make a long story short, this caused...
2
by: crash | last post by:
I have a program that i changed over from using char *'s to using ansistrings. Previously it had been: char string1; char string2; strcpy(string1,string2); now i use:
6
by: afraze | last post by:
Hi! My problem is that: When i declare an AnsiString function in my Form.h("Form.h" is an ex. name) i am getting this error: :Unresolved external ' __fastcall System::TObject::ToString()...
5
by: Michael Bell | last post by:
I have just done (but done badly in) the Open University course "MT262: Putting computers to work". Borland Builder 5 is supplied as part of the course. It uses the data-type AnsiString for strings...
8
by: sparkydarky | last post by:
I have a bunch of strings in a database that have in them a number I want to extract. Here's the example code I've been working with: AnsiString tmp = "AMjsdfdsdfj 457756 some description"; int...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...
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?

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.