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
Solved

Plz Help

Posted on 2002-03-07
6
254 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 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying 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…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.

861 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