?
Solved

Plz Help

Posted on 2002-03-07
6
Medium Priority
?
259 Views
Last Modified: 2012-05-04
hi,

I am new in Visual C++(Microsoft Visaul C++ 6), I got a question here, I have 2 CEdit control and 1 button on the form, i want to input 2 numbers in each of them, then click the button to get the result by CEdit1/CEdit2, and the result is a integer value, i was pissed off by this, seems like the conversion of the string and number make me really confusing, plz help me out of this, thx
0
Comment
Question by:PX
6 Comments
 
LVL 2

Expert Comment

by:jonnin
ID: 6847043
try casting everything to double, as explained below:

int a,b;
double d;

d = a/b; //d contains an int because
int/int gives an int, cast to double after this.

d = (double)(a)/(double)(b);
//now d has the fractional data as
double/double = double

0
 
LVL 1

Author Comment

by:PX
ID: 6847076
hi jonnin ,

Well, fisrt of all, how to get the those values I entered into the CEdit then, when I use the GetWindowText to retrive the values, it give a CString, how to make it to int?
0
 

Accepted Solution

by:
wenderson earned 200 total points
ID: 6848001
Instead of GetWindowText, you can use GetDlgItemInt and SetDlgItemInt.
Or if still want to use GetWindowText, you may convert it to integer using atoi, itoa, sprintf, strtol, etc.

Wenderson
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 11

Expert Comment

by:griessh
ID: 6955285
Dear PX

I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. You can always request to keep this question open. But remember, experts can only help you if you provide feedback to their questions.
Unless there is objection or further activity,  I will suggest to accept

     "jonnin"

comment(s) as an answer.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
0
 
LVL 1

Author Comment

by:PX
ID: 6959394
hi wenderson,

your comment is exactlly whant i need, sorry for this delay.
0
 

Expert Comment

by:wenderson
ID: 6960473
No problem, also, if you are using MFC, you can create a CString variable and attach it to editbox, so, to transfer the data all you have to do is call UpdateData.
UpdateDate(TRUE); // Copy the contents of the editbox to the variables

UpdateData(FALSE); // Copy the contents of the variables to the editbox

To attach the variables to the editbox you can do that in the resource editor or by calling DDX_Text in the DataExchange function.

Regards,

Wenderson Teixeira
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question