?
Solved

Plz Help

Posted on 2002-03-07
6
Medium Priority
?
257 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

752 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