473,503 Members | 2,105 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to write the simplest Windows program?

This is the program:
The Form has 3 TextBoxes and 1 Button. The user uses the keyboard to
enter a number in each of the two first TexBoxes, presses the Button,
and the sum of the numbers appears in the third TextBox.

In Borland Builder the OnClick event of the Button can look like this
(if the TextBoxes are named N1, N2 and N3):

void __fastcall TForm1::Button1Click(TObject *Sender)
{
double A = N1->Text.ToDouble();
double B = N2->Text.ToDouble();

N3->Text=A+B;
}

In MS Visual C++ 2005 Express Edition I miss the ToDouble function. How
can it be done here? Can anyone help ?

Regards Knut
Feb 19 '07 #1
6 2009
Knut Olsen-Solberg wrote:
This is the program:
The Form has 3 TextBoxes and 1 Button. The user uses the keyboard to
enter a number in each of the two first TexBoxes, presses the Button,
and the sum of the numbers appears in the third TextBox.

In Borland Builder the OnClick event of the Button can look like this
(if the TextBoxes are named N1, N2 and N3):

void __fastcall TForm1::Button1Click(TObject *Sender)
{
double A = N1->Text.ToDouble();
double B = N2->Text.ToDouble();

N3->Text=A+B;
}

In MS Visual C++ 2005 Express Edition I miss the ToDouble function. How
can it be done here? Can anyone help ?

Regards Knut
Take a look at std::strtod in <cstdlib>.

That should convert a string to a double. You'll have to pass it a
C-string though, but your text control surely has some conversion for this.

--John Ratliff
Feb 19 '07 #2
Knut Olsen-Solberg napisał(a):
This is the program:
The Form has 3 TextBoxes and 1 Button. The user uses the keyboard to
enter a number in each of the two first TexBoxes, presses the Button,
and the sum of the numbers appears in the third TextBox.

In Borland Builder the OnClick event of the Button can look like this
(if the TextBoxes are named N1, N2 and N3):

void __fastcall TForm1::Button1Click(TObject *Sender)
{
double A = N1->Text.ToDouble();
double B = N2->Text.ToDouble();

N3->Text=A+B;
}

In MS Visual C++ 2005 Express Edition I miss the ToDouble function. How
can it be done here? Can anyone help ?

Regards Knut
double A = Double::Parse(Text);

Regards Ryszard
Feb 19 '07 #3
Ryszard wrote:
Knut Olsen-Solberg napisał(a):
>This is the program:
The Form has 3 TextBoxes and 1 Button. The user uses the keyboard to
enter a number in each of the two first TexBoxes, presses the Button,
and the sum of the numbers appears in the third TextBox.

In Borland Builder the OnClick event of the Button can look like this
(if the TextBoxes are named N1, N2 and N3):

void __fastcall TForm1::Button1Click(TObject *Sender)
{
double A = N1->Text.ToDouble();
double B = N2->Text.ToDouble();

N3->Text=A+B;
}

In MS Visual C++ 2005 Express Edition I miss the ToDouble function.
How can it be done here? Can anyone help ?

Regards Knut

double A = Double::Parse(Text);

Regards Ryszard

Thanks!
Still I have a problem getting A+B back to N3->Text. Can you show me
this too?

Regards Knut
Feb 20 '07 #4
On Feb 20, 10:21 am, Knut Olsen-Solberg <k...@hist.nowrote:
Ryszard wrote:
Knut Olsen-Solberg napisał(a):
This is the program:
The Form has 3 TextBoxes and 1 Button. The user uses the keyboard to
enter a number in each of the two first TexBoxes, presses the Button,
and the sum of the numbers appears in the third TextBox.
In Borland Builder the OnClick event of the Button can look like this
(if the TextBoxes are named N1, N2 and N3):
void __fastcall TForm1::Button1Click(TObject *Sender)
{
double A = N1->Text.ToDouble();
double B = N2->Text.ToDouble();
N3->Text=A+B;
}
In MS Visual C++ 2005 Express Edition I miss the ToDouble function.
How can it be done here? Can anyone help ?
Regards Knut
double A = Double::Parse(Text);
Regards Ryszard

Thanks!
Still I have a problem getting A+B back to N3->Text. Can you show me
this too?
Might be a better way of doing this but this ought to work:

N3->Text = Convert::ToString(A + B, 10);

The 10 at the end means you want it in base 10, I hope this works for
non-integers too. By the way, this is kind of off-topic here, in the
future you should ask questions like these in a Microsoft/.Net-
specific newsgroup, perhaps microsoft.public.dotnet.languages.vc will
do.

--
Erik Wikström

Feb 20 '07 #5
Erik Wikström wrote:
On Feb 20, 10:21 am, Knut Olsen-Solberg <k...@hist.nowrote:
>Ryszard wrote:
>>Knut Olsen-Solberg napisał(a):
This is the program:
The Form has 3 TextBoxes and 1 Button. The user uses the keyboard to
enter a number in each of the two first TexBoxes, presses the Button,
and the sum of the numbers appears in the third TextBox.
In Borland Builder the OnClick event of the Button can look like this
(if the TextBoxes are named N1, N2 and N3):
void __fastcall TForm1::Button1Click(TObject *Sender)
{
double A = N1->Text.ToDouble();
double B = N2->Text.ToDouble();
N3->Text=A+B;
}
In MS Visual C++ 2005 Express Edition I miss the ToDouble function.
How can it be done here? Can anyone help ?
Regards Knut
double A = Double::Parse(Text);
Regards Ryszard
Thanks!
Still I have a problem getting A+B back to N3->Text. Can you show me
this too?

Might be a better way of doing this but this ought to work:

N3->Text = Convert::ToString(A + B, 10);

The 10 at the end means you want it in base 10, I hope this works for
non-integers too. By the way, this is kind of off-topic here, in the
future you should ask questions like these in a Microsoft/.Net-
specific newsgroup, perhaps microsoft.public.dotnet.languages.vc will
do.

--
Erik Wikström
No, this did not work (maybe just a little correction needed?), but I
found something that worked:
T3->Text = (A+B).ToString();

Thanks Knut
Feb 20 '07 #6
Knut Olsen-Solberg napisa³(a):
Ryszard wrote:
>Knut Olsen-Solberg napisa³(a):
>>This is the program:
The Form has 3 TextBoxes and 1 Button. The user uses the keyboard to
enter a number in each of the two first TexBoxes, presses the Button,
and the sum of the numbers appears in the third TextBox.

In Borland Builder the OnClick event of the Button can look like this
(if the TextBoxes are named N1, N2 and N3):

void __fastcall TForm1::Button1Click(TObject *Sender)
{
double A = N1->Text.ToDouble();
double B = N2->Text.ToDouble();

N3->Text=A+B;
}

In MS Visual C++ 2005 Express Edition I miss the ToDouble function.
How can it be done here? Can anyone help ?

Regards Knut

double A = Double::Parse(Text);

Regards Ryszard


Thanks!
Still I have a problem getting A+B back to N3->Text. Can you show me
this too?

Regards Knut
N3->Text = A.ToString();

Regards Ryszard
Feb 20 '07 #7

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

Similar topics

5
2635
by: John Ladasky | last post by:
Hi, folks, At the beginning of 2003, I was a frustrated computer user, and lapsed programmer, with problems to solve that screamed for programming. Thanks to the Python language and community, I...
15
3274
by: Viviana Vc | last post by:
How can I programatically do the equivalent of the following: cacls "C:\Program Files\test" /T /G Everyone:f ? Thanks, Viv
8
2492
by: Zheng Da | last post by:
I don't know where should I ask the question, so send the email to this group. I choose this group, because I want to write the program with c++ :) I want to write a program which support...
3
1746
by: Bore Biko | last post by:
Dear, I don't have enought money to by a original Visual C++, so I use Visual C++ 6.0 Enterprise edition, this version doesen't have a HELP. Most of my friends programmers praise C++, as a...
2
5755
by: Alvin Lau | last post by:
Can I write pocket PC bluetooth program by using C# ? It seems so difficult to find the library? If it is possible , where can i find the reference of these kind of program ? *** Sent via...
2
21940
by: Ilkka | last post by:
I have created an C++ application with Windows Forms, ADO and SQL server 2005. Now I need to change something and started debugging the code. Then suddenly I receive an error. "An unhandled...
12
1338
by: =?Utf-8?B?QW5kcmV3?= | last post by:
I am simple tryint to learn how to use the ADO.NET code. Can anybody tell me if I am using it right or not? Imports System.Data.sqlclient Imports System.Data Public Class Form1 Inherits...
3
2028
by: Ben Keshet | last post by:
I have a probably simple beginner's question - I have a script that I am currently able to print its output. instead, i want to write it into a file - I tried different versions of write() but...
65
5019
by: Hongyu | last post by:
Dear all: I am trying to write to a file with full directory name and file name specified (./outdir/mytestout.txt where . is the current directory) in C programming language and under Unix, but...
0
7093
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
7287
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
7348
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
7467
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
5592
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
3175
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
3166
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1519
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 ...
0
397
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.