How do I convert the contents of a textbox to a double for mathmateical
operations? I'm using a form to collect values and when the user clicks OK,
the vlaues are used for calcualtions... but they need to be double data type.
Then, after the calculations, how to do I convert the double back into the
data type needed by the textbox control?
Thanks,
Scott 8 4457
double aux = Int64.Parse(textbox.Text);
aux += aux;
textbox.Text = aux.ToString();
I hope this help you.
Ernesto Lores (Bcn)
"Scott" <Sc***@discussions.microsoft.com> escribió en el mensaje
news:36**********************************@microsof t.com... How do I convert the contents of a textbox to a double for mathmateical operations? I'm using a form to collect values and when the user clicks
OK, the vlaues are used for calcualtions... but they need to be double data
type. Then, after the calculations, how to do I convert the double back into the data type needed by the textbox control?
Thanks, Scott
Scott,
You can use double.Parse(textbox.Text) to convert it to a double, and then
use textbox.Text = answer.ToString()
Is that what you need?
Joel http://www.rosscode.com
"Scott" <Sc***@discussions.microsoft.com> wrote in message
news:36**********************************@microsof t.com... How do I convert the contents of a textbox to a double for mathmateical operations? I'm using a form to collect values and when the user clicks
OK, the vlaues are used for calcualtions... but they need to be double data
type. Then, after the calculations, how to do I convert the double back into the data type needed by the textbox control?
Thanks, Scott
Thanks. That worked...
"e-lores" wrote: double aux = Int64.Parse(textbox.Text); aux += aux; textbox.Text = aux.ToString();
I hope this help you. Ernesto Lores (Bcn) "Scott" <Sc***@discussions.microsoft.com> escribió en el mensaje news:36**********************************@microsof t.com... How do I convert the contents of a textbox to a double for mathmateical operations? I'm using a form to collect values and when the user clicks OK, the vlaues are used for calcualtions... but they need to be double data type. Then, after the calculations, how to do I convert the double back into the data type needed by the textbox control?
Thanks, Scott
double aux = double.Parse(textbox.Text) ;
is the correct form.
(Int64 is used to convert to long integer)
"e-lores" <e_*****************@yahoo.es> escribió en el mensaje
news:es**************@TK2MSFTNGP09.phx.gbl... double aux = Int64.Parse(textbox.Text); aux += aux; textbox.Text = aux.ToString();
I hope this help you. Ernesto Lores (Bcn) "Scott" <Sc***@discussions.microsoft.com> escribió en el mensaje news:36**********************************@microsof t.com... How do I convert the contents of a textbox to a double for mathmateical operations? I'm using a form to collect values and when the user clicks OK, the vlaues are used for calcualtions... but they need to be double data type. Then, after the calculations, how to do I convert the double back into
the data type needed by the textbox control?
Thanks, Scott
Thanks for help! The code I wrote is below. So far, everything is working
just fine...
double bearingOne = double.Parse(textBox1.Text) ;
double bearingTwo = double.Parse(textBox2.Text) ;
double angleBetween = bearingOne + bearingTwo ;
textBox3.Text = angleBetween.ToString() ;
Thanks,
Scott
"Joel Ross" wrote: Scott,
You can use double.Parse(textbox.Text) to convert it to a double, and then use textbox.Text = answer.ToString()
Is that what you need?
Joel http://www.rosscode.com
"Scott" <Sc***@discussions.microsoft.com> wrote in message news:36**********************************@microsof t.com... How do I convert the contents of a textbox to a double for mathmateical operations? I'm using a form to collect values and when the user clicks OK, the vlaues are used for calcualtions... but they need to be double data type. Then, after the calculations, how to do I convert the double back into the data type needed by the textbox control?
Thanks, Scott
Any thoughts about when user doesn't enter a valid real number?? :)
Please explore Double.TryParse method
Maqsood Ahmed
Kolachi Advanced Technologies http://www.kolachi.net
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
I recognize the need to add some form of input validation but, since I'm new
to c#, I still need to figure oout that part. I'm collecting the values from
textboxes on a form and would prefer to throw a message / flag instructing
the user to enter a valid value.
Any suggestions / code samples are greatly appreciated.
Thanks,
Scott
"Maqsood Ahmed" wrote: Any thoughts about when user doesn't enter a valid real number?? :) Please explore Double.TryParse method
Maqsood Ahmed Kolachi Advanced Technologies http://www.kolachi.net
*** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
Maybe you can use ...
1. ... KeyPress event (you control key by key)
2. ... Validating event (you control the value inserted)
Ernesto Lores (Bcn)
"Scott" <Sc***@discussions.microsoft.com> escribió en el mensaje
news:88**********************************@microsof t.com... I recognize the need to add some form of input validation but, since I'm
new to c#, I still need to figure oout that part. I'm collecting the values
from textboxes on a form and would prefer to throw a message / flag instructing the user to enter a valid value.
Any suggestions / code samples are greatly appreciated.
Thanks, Scott
"Maqsood Ahmed" wrote:
Any thoughts about when user doesn't enter a valid real number?? :) Please explore Double.TryParse method
Maqsood Ahmed Kolachi Advanced Technologies http://www.kolachi.net
*** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Joseph Suprenant |
last post by:
I have an array of unsigned chars and i would like them converted to
an array of ints. What is the best way to do this? Using RedHat 7.3
on an Intel Pentium 4 machine. Having trouble here, hope...
|
by: Keith MacDonald |
last post by:
Hello,
Is there a portable (at least for VC.Net and g++) method to convert text
between
wchar_t and char, using the standard library? I may have missed something
obvious, but the section on...
|
by: genc_ymeri |
last post by:
Hi,
Well, I'm looking around for another opinion. We have two webservers, the
legacy one writen in ASP and the new one in ASP.Net.
Once a user logs in the ASP.Net web app, the session of the...
|
by: Nelson |
last post by:
In my web form, I am converting all lower case letters to upper case when
the user types the characters in the edit boxes. I am achieving that by
injecting client side script (onkeyup event) for...
|
by: Hugo Amselschlag |
last post by:
Hi there,
I've implemented a local system hook to suppress certain windows beeing
displayed by the axWebbrowser control. Now I need some more information
before I can decide, whether to suppress...
|
by: Bob Alston |
last post by:
Anyone have experience with converting an access app from Jet database
to Mysql? I am specifically looking for any changes I would have to
make to my access forms, queries, modules, vba code, etc....
|
by: SLC via DBMonster.com |
last post by:
Hello I'm a newbie to this and I need help, please
My question is, we currently have a IDMS db and will be converting to DB2.
What are the things I should do? The IDMS has not been documented very...
|
by: psbasha |
last post by:
Hi ,
When ever we read any data from file ,we read as a single line string ,and we convert the respective field data available in that string based on the data type ( say int,float ).
...
|
by: py_genetic |
last post by:
Hello,
I'm importing large text files of data using csv. I would like to add
some more auto sensing abilities. I'm considing sampling the data
file and doing some fuzzy logic scoring on the...
|
by: ssubbarayan |
last post by:
Hi all,
I am trying a program to convert floating point values to a byte array
and printing the same to the screen.The idea behind this is we already
have an existing function which can do byte...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |