Fog Creek Software
Discussion Board




Convert String to Float

Hi,
  How can I convert one variable string to float?
  How can I read the text from one textBox and convert to float?

Thanks Mário Wilson

Mário Wilson Moreira
Monday, April 05, 2004

In C#.

  Mário Wilson

Mário Wilson Moreira
Monday, April 05, 2004

You're at such a rudimentary baby-steps stage that you can't convert a string to a float and you think it's reasonable to pollute online boards with questions about it?  This is precisely the sort of situation that merits a "RTFM". Virtually any related search gets an excellent match in MSDN help immediately.

.
Monday, April 05, 2004

Well said, er, written, ".".

I mean, come on, Mario, what are ya gonna do next, ask us to write the friggin' code for ya? Fuggedaboutit.

You're fired!
Monday, April 05, 2004


Does C# have atof() ? atod()?

it'll be something like that.

Matt H.
Monday, April 05, 2004

Man, it sounds like slashdot around here. 

Look into float.Parse on MSDN.

Matt Watson
Monday, April 05, 2004

Matt,

Shut the f*k up. Mario asked a dumb-a** question, so he got slapped down, as he should have. No one has any business asking a question easily answered by searching the documentation.

You're fired!
Monday, April 05, 2004

I am sure that none of you have ever done that either.  Cut the guy a break.

Matt Watson
Monday, April 05, 2004

Sure he should have googled it before coming here but that does not mean that we all have to jump down his throat for it.  I probably wouldn't have even answered it if it was not for the rudeness it was responded with.  How about something along the lines of "Mario, please check out the c# documenation on MSDN.  Your answer will be found there" instead of blasting him. 
This is exactly the reason why I hate other posting boards, people get all high and might and try and see who can blast the other person more.  JOS has never been that way and hopefully never will. 

Matt Watson
Monday, April 05, 2004

http://www.catb.org/~esr/faqs/smart-questions.html ;)

Caranguejo
Monday, April 05, 2004

What happened to the messages not suitable being removed? I haven't seen anything getting tagged recently either. Is a release coming up soon? Where is Asok at Fog Creek to take care of these things?

Anyway, I thought the criteria of posting a message was that if it is good enough, it'll stay.

So if you want to answer a question which seems to stick around for who knows what reason, then do it. If you think it is stupid, *ignore* it.

Don't use this board to dump your anger and frustration either. There are therapists for that.

entell
Monday, April 05, 2004

The System.Convert class does it for ya.

System.Convert.ToDouble is what you're looking for.

Alternately, you can import Microsoft.VisualBasic and get the CDbl function.

Ankur
Monday, April 05, 2004

Hi,
Sincerely, I don't want to take your time with questions that you think that "pollute online boards" (  "." ), ("You're fired!").
So I asked you (  "." ), ("You're fired!"):
"Wath the color of the white hourse of Napoleon??"

Thanks Matt Watson

  Mario Wilson

Mário Wilson Moreira
Monday, April 05, 2004

Napoleon's white hose was grey.  Horses cannot be registered as white, they are either grey or albino.  Napoleon's white horse did not have red eyes, therefore, it was grey.

K
Monday, April 05, 2004

I'm reminded of an episode of "Travel Sick" (presented by Grub Smith), where he asked Americans (or Canadians, who can tell the difference?) questions like "What is Prince Charles' first name?", "Which monarch was the Victorian era named after?" and other similar things.


Monday, April 05, 2004

It's rose colour!!

Mário Wilson Moreira
Monday, April 05, 2004

"Napoleon's white hose" ... which he wore under his pants? :)

sgf
Monday, April 05, 2004

Welllll, you don't get much time to change your socks on the battlefield. So.. Yeah, his white hose were grey too.  :-)

K
Monday, April 05, 2004

`How about something along the lines of "Mario, please check out the c# documenation on MSDN.  Your answer will be found there" instead of blasting him. '

I pray that you're not an officer of the law.

"Excuse me sir, you appear to have tossed that McDonalds bag of garbage out of your car window. I am going to presume that you're not just a selfish lazy ignoramus, but instead you mistakingly think this is okay. Please don't do it. Oh, by the way I'll run over there and pick it up and put it in the garbage for you."

"Hi, sir, we meet again! I notice that you tossed a bag of used tampons out your car window. I presume that you're not a selfish lazy ahole, but instead are just misguided. Don't worry, though, I'll run over there and pick that up for you. Have a good day.

.
Monday, April 05, 2004

Can you please explain to me the coorelation between being nice to someone who asked a question and not arresting someone who is breaking the law? 

Secondly, there is a fallacy in your reasoning becuase cops do what you said all of the time.  I know many people (myself  included) who have been let off with a warning for speeding or the like. 

There is such a thing as compassion.  Cops have it, developers have it, we all do.  We just need to excercise it a little more.

Matt Watson
Monday, April 05, 2004

"Can you please explain to me the coorelation between being nice to someone who asked a question and not arresting someone who is breaking the law?"

Note that earlier I used the terminology of them "polluting" the message boards, which is what such incredibly simpleton questions are, so I stuck with the analogy - they are like tossing a McDonalds bag out of your car -- It's easier for the perpetrator. Indeed, the only reason why such RTFM-deserving posts don't get blasted back into the stone ages is because it gives some low-skill developers a moment to shine. "Oooh, here's my big chance to answer something!"

"Secondly, there is a fallacy in your reasoning becuase cops do what you said all of the time.  I know many people (myself  included) who have been let off with a warning for speeding or the like. "

My analogy, like virtually all analogies, isn't fool-proof. To try to expand upon its comparison, what I did above is basically a "verbal warning" -- I didn't financially fine them, or kick them off the board, or banish them from the internet. The verbal warning is there to correct their behaviour, as well as a warning to others.

.
Monday, April 05, 2004

You flaming people who ask perfectly reasonable questions is far more "polluting" to this board than asking the question in the first place.  If you can't be constructive, don't answer.  Or better yet, go away.

MikeMcNertney
Monday, April 05, 2004

"You flaming people who ask perfectly reasonable questions is far more "polluting" to this board than asking the question in the first place.  If you can't be constructive, don't answer.  Or better yet, go away."

Ah, the classic moronic response, straight out of the textbook.

The "reasonable" question, as an aside, is BRUTALLY rudimentary, and betrays the fact that the asker didn't so much as bother to type convert into the MSDN index, much less go on Google and type in a request - such a thing would require them to mentally interpret the results. Too much work!

This isn't a subjective conversational topic, or even a complex issue that might help future searchers: It is a moronic waste of bits that would . I am merely saying what every normal peson out there is thinking, and in any case moronic questions like this usually get deleted from the board pronto anyways. I suspect that it's hung around as a head-on-a-pike warning for the next idiot.

.
Monday, April 05, 2004

So now you are trying to blast my programming skills (as well as others here) for trying to help someone out.  That is just ridiculous.  Maybe if you would step down off of your high horse and take off your "World's Best Programmer" hat long enough, you will see that you are just trying to cover up the fact that the way you handled it was completely inappropriate. 

Matt Watson
Monday, April 05, 2004

"you will see that you are just trying to cover up the fact that the way you handled it was completely inappropriate. "

This is great material, thanks.

In any case, saying that I'm trying to 'cover up' is hilariously delusional given then I have stuck my feet in the ground and refused to cede ground to some multiple-pseudonym posters and bleeding hearts. Suck it up cowboy, your lame debating tricks aren't working here.

By the way - I need to draw a circle. What's the value of pi?

.
Monday, April 05, 2004

Maybe we need a 'rule' that when posting a question, you need to include what you've done so far to find out the answer yourself.

James B.
Monday, April 05, 2004

Dear dot,
              You don't need to know the value of pi to draw a circle.

              It's not a question of compassion; it's one of common courtesy, and you have shown yourself sadly lacking in it.

Stephen Jones
Monday, April 05, 2004

Seriously, would all you nay-sayers rather see this forum turned into just another n00b hang-out with all the intellectual numbing conversations that go along with that scenario?

The question was garbage. (".") maybe could have been more polite in some minds, but was fundamentally on the right on target. IMHO, he was maybe too nice, since he didnt drop any f-bombs in there...

Anon-y-mous Cow-ard
Monday, April 05, 2004

"You don't need to know the value of pi to draw a circle."

2л = 360 degrees for the majority of math libraries. AKA radians.

.
Monday, April 05, 2004

3.1415 9265 3589 7932 3846 2643 3832 7950 2884 1971 6939 9375 1058 2097 4944 5923 0781 6406 2862 0899 8628 0348 2534 2117 0679 or so.

Michael Eisenberg
Monday, April 05, 2004

"We are not here to be nice to people."

Quote by Umm me.

This doctrine does not imply that you have to be nasty to people, only that in being nice to them what you're really doing is taking away their responsibility for acting and being responsible for that act.

The correct non-nice response is to say 'have a look at the properties of the variable type you are working with, you'll figure it out.'  Responding with RTFM is not true non-nice behaviour, since its likely the person so responding didn't know themselves, (it takes as long to direct positively as it does to deride negatively), and so they were simply being boorish because they recognise that it was a question betraying complete lack of knowledge.

We are not here to be nice to people.
As above so below.
Per adua ad astrae
and so on...

Simon Lucy
Monday, April 05, 2004

"Responding with RTFM is not true non-nice behaviour, since its likely the person so responding didn't know themselves"

Yes, and people who drive nice cars have small penises, right?

Maybe that makes you feel warm and fuzzy on the inside, and a nice to think that all the meanies are just ignorant, but it's a tired bit of rhetoric : Virtually any semi- to advanced board will earn you a RTFM if you ask something idiotic, because it's a grossly disrespectful act to presume that others are so eager, and you're so important, that they'll do your petty dirty work. Feel free to rush to answer, but me I'll just throw out some insults and a RTFM.

Jimmy the Geek
Monday, April 05, 2004

>which he wore under his pants?

Brown, probably.


Tuesday, April 06, 2004

Actually, I needed this answer. Glad someone was dumb enough to ask it, apparently.

Me
Friday, April 23, 2004

If the question had of been answered in the first place the thread would have been over a long time ago..

Rolling Eyes
Saturday, April 24, 2004

wow.  I guess it is true what they say about arguing on the internet.

Lame thread. Funny, but lame.
Monday, April 26, 2004

If any forum was a complete waste of space, this is clearly it.

Kick Ass
Wednesday, April 28, 2004

What a bunch of trolls.  It is ignorant to assume that one does not know how to program becauase they dont know how to convert a float to string in C#.  Each language has different constructs for this.  Programming is but an orchestrated use of simple constructs (hence all programming languages being but translated to assembly and then machine code for execution).

Its been my experience that whenever someone gives someone shit for answering a simple question, its because the person giving them shit DOESNT KNOW THE ANSWER.

To convert a string to float, use.

float value = (float)Convert.ToDouble(<string value>);

tonicxt
Saturday, May 08, 2004

That guy '.' is a total twat. Your analogies are rubbish, your arguments are fatally flawed, no-one likes you and you smell of fish.

Dot is a fud
Thursday, May 20, 2004

I needed this answer too, so I googled it and got this board.  This is hysterical, although really way overdone.

Anyone interested in tossing me some good starting places for programming callback components?  (progress bars and cancel buttons)

Shtark

Shtark
Monday, May 24, 2004

Ok look, Railing on some guy for posting a "simpleton" question is really lame.  I'm sure you all are these bada$$ coders with mad skillz but give a guy a break.  I found out how to convert a string to float by googling and found this site, so maybe this one "simpleton" post just helped a shite load of others like me who're coming from C++ and never really done any web stuff like C#.  You'll probably rail on me too for defending the guy.  A terse, google it would have sufficed.  No need to show how big of an arse you are by flaming the guy for a quick and easy question

new to web dev
Thursday, May 27, 2004

*  Recent Topics

*  Fog Creek Home