Solved

Plz Help

Posted on 2002-03-07
6
256 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 50 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

Technology Partners: 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!

Question has a verified solution.

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

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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.
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.

705 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