Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / April 2007

Tip: Looking for answers? Try searching our database.

Very stupid question part 2

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mark - 05 Apr 2007 02:36 GMT
Thanks Folks,

Now I need to go the other way. That is, have a textBox display a
representation of a double precision number. I have tried (amoung other
things):

textBox2->Text=F.ToString;

all resulting in errors unintelegible by me.

Signature

mark b

Nathan Mates - 05 Apr 2007 05:15 GMT
>Now I need to go the other way. That is, have a textBox display a
>representation of a double precision number. I have tried (amoung other
>things):

> textBox2->Text=F.ToString;

  Once again, the tried and true method in C/C++ is sprintf.
Don't knock it until you've tried it. For example:

 char tempStr[128];
 sprintf_s(tempStr, "%g", value);

  Simple, portable (well, except for the _s part), and has more
possible options than you can shake a stick at.

Nathan Mates
--
<*> Nathan Mates - personal webpage http://www.visi.com/~nathan/ 
# Programmer at Pandemic Studios -- http://www.pandemicstudios.com/
# NOT speaking for Pandemic Studios. "Care not what the neighbors
# think. What are the facts, and to how many decimal places?" -R.A. Heinlein
Cholo Lennon - 05 Apr 2007 07:04 GMT
If you want a C++ way (and not C (like Nathan Mates' solution) or .Net way), you can use stringstream or wstringstream (sprintf is
faster but is not type safe). See interpret_cast in Kevlin Henney's paper (Valued Conversions,
http://www.two-sdg.demon.co.uk/curbralan/papers/ValuedConversions.pdf). Also see lexical_cast (from the same author) in boost
libraries for an updated and more complete version of interpret_cast (http://www.boost.org/libs/conversion/lexical_cast.htm). These
converter templates are very flexible, simple and useful.

Regards

--
Cholo Lennon
Bs.As.
ARG

> Thanks Folks,
>
[quoted text clipped - 5 lines]
>
> all resulting in errors unintelegible by me.
Ben Voigt - 05 Apr 2007 14:41 GMT
> Thanks Folks,
>
[quoted text clipped - 3 lines]
>
> textBox2->Text=F.ToString;

ToString is a function, not a property.  The () are not optional in C++.
textBox2->Text=F.ToString();

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.