Solved

Plz Help

Posted on 2002-03-07
6
250 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 11

Expert Comment

by:griessh
Comment Utility
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
Comment Utility
hi wenderson,

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

Expert Comment

by:wenderson
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
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 goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

771 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now