Basic Managed C++ questions

A

all2neat

Hello,

I'm looking to teach myself managed C++. I'm trying to make a simple
application. How do I import the number from a text box into a variable
of data type long.

in vb i would do something like

dim var as long
var = textbox.text


and it would work. Now when i do in C++
long Number = 0;
Number = txtNum->Text;

I get errors stating that it can't convert from string to int. any
suggestions on how to do this?
 
A

Alf P. Steinbach

* all2neat:
[snip]
I get errors stating that it can't convert from string to int. any
suggestions on how to do this?

E.g. boost::lexical_cast (see www.boost.org).

Or, you can use a std::istringstream yourself.

Or, you can use the C library's functions, or whatever conversion
function you find most convenient.


PS: Please note that Managed C++ is outside the scope of this newsgroup.
Happily your question turned out to have nothing to do with Managed
C++, and so I could answer it in good conscience. Also, slightly
off-topic, note that Managed C++ has been supplanted by C++/CLI.
 
E

EventHelix.com

This would be off topic here.

Try the newsgroup:

microsoft.public.dotnet.languages.vc newsgroup.
 
R

roberts.noah

all2neat said:
Hello,

I'm looking to teach myself managed C++.

Managed C++ and actual C++ have little in common; they are not the same
language. Here we talk about C++, not MS's bastardization of it. Any
answer you get here is likely to be completely unbeneficial to you. Go
to a microsoft .net newsgroup.
 
T

Tomás

all2neat posted:
Hello,

I'm looking to teach myself managed C++. I'm trying to make a simple
application. How do I import the number from a text box into a variable
of data type long.

in vb i would do something like

dim var as long
var = textbox.text


and it would work. Now when i do in C++
long Number = 0;
Number = txtNum->Text;

I get errors stating that it can't convert from string to int. any
suggestions on how to do this?


Looks like you're using something like MFC.

I only every use the Windows API directly, so I'd probably use GetDlgItemInt
or GetDlgItemText.

You'll get much greater help on a Windows specific programming newsgroup.


-Tomás
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,431
Messages
2,571,678
Members
48,796
Latest member
Greg L.

Latest Threads

Top