473,799 Members | 3,121 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Parse / textBox.Text question

When I code

Double.Parse(te xtBox1.Text)

I get an error

How can I convert a text box entry to a numeric?

Please give a code example, if you know the answer.

--
Patrick De Ridder
ng****@freeler. nl
Nov 15 '05 #1
1 7089
mk
Hi,
You should only receive an error when the Text property
is null, or is not a number, for example "1" will parse
correctly, "" or "Not a number" will not.
I would suggest that you wrap your Double.Parse statement
in try/catch and check for an error that states something
like 'the input string was an incorrect format', etc.

HTH,

Martin

-----Original Message-----
When I code

Double.Parse(t extBox1.Text)

I get an error

How can I convert a text box entry to a numeric?

Please give a code example, if you know the answer.

--
Patrick De Ridder
ng****@freeler .nl
.

Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3342
by: c0uch | last post by:
the first and third methods are in a usercontrol object. txtValue is a TextBox the float.parse in the if statement on line 3 always works fine. the second float.parse in the third method is quirky: if the program just runs it will always break on that line, vc# 2005 beta2 shows txtValue.Text as null at this point. However, if I put a breakpoint on the first float.parse (on line 3), and then step out until i reach the second float.parse,...
7
2921
by: sara | last post by:
Hi to all i have string y; int x=int.parse(y); when i run the application this exeption is trewn /////////////////////////////////////// Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
3
3085
by: Slonocode | last post by:
I have some textboxes bound to an access db. I wanted to format the textboxes that displayed currency and date info so I did the following: Dim WithEvents oBidAmt As Binding oBidAmt = New Binding("Text", Me.Ds1, "Items.BidAmt") txtBidAmt.DataBindings.Add(oBidAmt) Private Sub oBidAmt_Format(ByVal sender As Object, ByVal e As System.Windows.Forms.ConvertEventArgs) Handles oBidAmt.Format
2
2406
by: mike | last post by:
how do I parse a textbox of text separated by carriage returns? I have a web form with a textbox, when the user presses submit I would like to process the text in the textbox line by line. How can I iterate through it line by line and do something on each line of text? Thanks for any help, Mike
5
5146
by: js | last post by:
I have a textbox contains text in the format of "yyyy/MM/dd hh:mm:ss". I need to parse the text using System.DateTime.Parse() function with custom format. I got an error using the following code. Could someone help me with the customization? Thanks. String was not recognized as a valid DateTime. at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles) at System.DateTime.Parse(String s, IFormatProvider...
10
2483
by: garyusenet | last post by:
I have a multiline textbox. The size of the text box should be 75 characters wide, and 5 lines in height like this: - <---75 characters--> <---75 characters--> <---75 characters--> <---75 characters--> <---75 characters-->
7
2561
by: pedrito | last post by:
I get exception trying to parse this URI: http://-eeayr4mwvtw998.usercash.com/ But IE and Firefox have no problem opening it. The parse exception is actually happening inside an HTTPWebRequest so I guess there's no much I can do about it one wary or the other, unless there's some way to encode it so that it still goes where it's supposed to go but is actually parseable by the URI parser as well.
1
2328
by: schaf | last post by:
Hi NG! I have a little question about the localization of a double. If I use the CultureInfo "en-US" I have the following behavior: 1.) If I enter the value 2.5 into a textbox the double.Parse(text1.Text) returns 2.5 as expected. 2.) If I enter the value 2,5 into a textbox the double.Parse(text1.Text) returns 25...why 25 and not 2500. The , is the group-separator.
6
1535
by: nomad | last post by:
Hi, I am writing a maintenance site for my department. One of the pages displays XML from the database in a GridView. I would like to be able to edit the cell, which I can currently do, but parse the contents of the cell when updating to make sure what is saved into the databse is proper XML. Any suggestions on how I could do this would be greatly appreciated.
0
10482
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10251
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10027
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9072
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7564
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6805
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.