473,405 Members | 2,349 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,405 software developers and data experts.

How to convert from string to integer?



I am working with MS Visual C++ .net 2003.

With your help, thank you, I am able to take data from the user through a
text box of a form and show the information on label of another form. But I
discovered that the data that I collected was not in such a format by which
I can do simple arithmetic operations on them. I want to be able to
manipulate the collected data arithmetically such as adding and multiplying
them. I would be please if someone can help converting this code in a way
that I can be able to manipulate the the collected data arithmetically. In
other words, I would like to have the date in int or double, instead of
string.

Below are snip shots of two classes. Form1 and ResultOut. From the first
class I show the event handler and from the second class I show the
property.

//Form1 :- Form1.h:

public __gc class Form1 : public System::Windows::Forms::Form

{

..

..

..

..

private: System::Void OKBtn_Click(System::Object * sender,
System::EventArgs * e)

{

//Create dialog

ResultOut* box = new ResultOut();

//Fill fill in data

box->Result = Form1::NumInBox->Text;

//Show dialog

if (box->ShowDialog() == DialogResult::OK)

{

box->Result; //get is used

}

};

//Form2:- ResultOut.h:

public __gc class ResultOut : public System::Windows::Forms::Form

{

..

..

..

..

..

..

public:

__property void set_Result(String* n){resultOutLbl->Text = n;}

__property String* get_Result(){return resultOutLbl->Text;}

};


May 1 '07 #1
2 1520
Allen Maki <al*******@sbcglobal.netwrote:
I am working with MS Visual C++ .net 2003.

With your help, thank you, I am able to take data from the user through a
text box of a form and show the information on label of another form. But I
discovered that the data that I collected was not in such a format by which
I can do simple arithmetic operations on them. I want to be able to
manipulate the collected data arithmetically such as adding and multiplying
them. I would be please if someone can help converting this code in a way
that I can be able to manipulate the the collected data arithmetically. In
other words, I would like to have the date in int or double, instead of
string.
See Int32.Parse and Double.Parse, along with Double.TryParse.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
May 1 '07 #2
use atoi function

"Allen Maki" <al*******@sbcglobal.netwrote in message
news:JE****************@newssvr23.news.prodigy.net ...
>

I am working with MS Visual C++ .net 2003.

With your help, thank you, I am able to take data from the user through a
text box of a form and show the information on label of another form. But
I discovered that the data that I collected was not in such a format by
which I can do simple arithmetic operations on them. I want to be able to
manipulate the collected data arithmetically such as adding and
multiplying them. I would be please if someone can help converting this
code in a way that I can be able to manipulate the the collected data
arithmetically. In other words, I would like to have the date in int or
double, instead of string.

Below are snip shots of two classes. Form1 and ResultOut. From the first
class I show the event handler and from the second class I show the
property.

//Form1 :- Form1.h:

public __gc class Form1 : public System::Windows::Forms::Form

{

.

.

.

.

private: System::Void OKBtn_Click(System::Object * sender,
System::EventArgs * e)

{

//Create dialog

ResultOut* box = new ResultOut();

//Fill fill in data

box->Result = Form1::NumInBox->Text;

//Show dialog

if (box->ShowDialog() == DialogResult::OK)

{

box->Result; //get is used

}

};

//Form2:- ResultOut.h:

public __gc class ResultOut : public System::Windows::Forms::Form

{

.

.

.

.

.

.

public:

__property void set_Result(String* n){resultOutLbl->Text = n;}

__property String* get_Result(){return resultOutLbl->Text;}

};


May 2 '07 #3

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

Similar topics

5
by: IamZadok | last post by:
Hi I was wondering if anyone knew how to convert a string or an integer into a Static Char. Thx
3
by: Convert TextBox.Text to Int32 Problem | last post by:
Need a little help here. I saw some related posts, so here goes... I have some textboxes which are designed for the user to enter a integer value. In "old school C" we just used the atoi function...
8
by: Carlos | last post by:
I have a strinf with comma separated field. Is is possible to convert it to a Structure ? Thanks
6
by: MrKrich | last post by:
I want to convert Hexadecimal or normal integer to Binary. Does VB.Net has function to do that? I only found Hex function that convert normal integer to Hexadecimal.
5
by: Mika M | last post by:
Hi! I've made little code to convert string into hex string... Public ReadOnly Property ToHexString(ByVal text As String) As String Get Dim arrBytes As Integer() = CharsToBytes(text) Dim sb...
14
by: Drew | last post by:
Hi All: I know I am missing something easy but I can't find the problem! I have a program which reads an integer as input. The output of the program should be the sum of all the digits in the...
20
by: Niyazi | last post by:
Hi all, I have a integer number from 1 to 37000. And I want to create a report in excel that shows in 4 alphanumeric length. Example: I can write the cutomerID from 1 to 9999 as: 1 ---->...
3
by: priyanka | last post by:
Hi there, I want to convert a String into integer. I get the string from a file using : string argNum; getline(inputStream,argNum); I now need to convert argNum into integer.
7
by: elliotng.ee | last post by:
I have a text file that contains a header 32-bit binary. For example, the text file could be: %%This is the input text %%test.txt Date: Tue Dec 26 14:03:35 2006...
7
by: shellon | last post by:
Hi all: I want to convert the float number to sortable integer, like the function float2rawInt() in java, but I don't know the internal expression of float, appreciate your help!
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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...
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
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
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...

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.