473,399 Members | 3,106 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

VB.net Casting to double from Textbox

Hey all, having some trouble with casting values inputed into a text box into double. In particular, I'm having trouble with the decimal. It's ok if someone puts in a number with a decimal when there is a number before the decimal, but if I input the decimal first I get a :

"Make sure your method arguments are in teh right format" error.




Private Sub tbPrice_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tbPrice.TextChanged



xPrice = System.Convert.ToDouble(tbPrice.Text)



End Sub

Where xPrice is a double. Any ideas? TIA
Mar 4 '08 #1
3 7193
Hey all, having some trouble with casting values inputed into a text box into double. In particular, I'm having trouble with the decimal. It's ok if someone puts in a number with a decimal when there is a number before the decimal, but if I input the decimal first I get a :

"Make sure your method arguments are in teh right format" error.




Private Sub tbPrice_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tbPrice.TextChanged



xPrice = System.Convert.ToDouble(tbPrice.Text)



End Sub

Where xPrice is a double. Any ideas? TIA
http://iheartdotnet.blogspot.com/2007/09/cast-vs-doubleparse-vs-converttodouble.html

Found that article, it lists 4 ways of casting but none of them worked for me. The Iconvertable was not available and the casting option was also not an option as the posters mentioned at the bottom.

I'm thinking that I'm gonna need to parse this thing first and do an 'if' for "." and then convert. Or what do you all think of concatenating 1+ textbox first?
Mar 4 '08 #2
Think I found a solution, use numbericupdown control! I never knew it existed :P
Mar 4 '08 #3
Plater
7,872 Expert 4TB
I would guess that it has something to do with language set you application is using. eng-us is fine to start it with a . and not a number.
Mar 4 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

231
by: Brian Blais | last post by:
Hello, I saw on a couple of recent posts people saying that casting the return value of malloc is bad, like: d=(double *) malloc(50*sizeof(double)); why is this bad? I had always thought...
7
by: I am Sam | last post by:
I have a DataGrid that is passing information to a stored procedure properly but the parameters aren't being casted properly. I was woundering if anyone can tell me how I should properly cast the...
4
by: Vincent | last post by:
Regarding the dropdetect function, defined as follows: Sub dropdetect(DropFrm As Form, DropCtrl As Control, Button As Integer, Shift As Integer, X As Single, Y As Single) Is it possible to...
8
by: Herby | last post by:
Given class B and C which inherit from class A They all override a method of the form: Add( A^ lhs, A^ rhs ); So A is abstract. So if i was defining Add for class B : B::Add( A^ lhs, A^ rhs...
2
by: harvie wang | last post by:
Hi, I want to implement a common Form with special interface, such as MovePoint(double,double). I create a interface first: namespace ABC.Test { public Interface IMyWindowInterface { void...
1
by: Jay Hamilton | last post by:
Hello, I am running into an invalid address alignment error on an HPUX box when I attempt to lookup a value in a STL map. The argument being passed in is a double, which is accessed from a...
14
by: kanepart2 | last post by:
Hi guys, I am having a problem with the following code snippet:- double x = (myReader); double y = (myReader); Resulting in the follwing compilation error: Cannot implicitly convert type...
17
by: sophia.agnes | last post by:
Hi , I was going through peter van der linden's book Expert C programming, in this book there is a section named "How and why to cast" the author then says as follows (float) 3 - it's a...
32
by: alex.j.k2 | last post by:
Hello all, I have "PRECISION" defined in the preprocessor code and it could be int, float or double, but I do not know in the code what it is. Now if I want to assign zero to a "PRECISION"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...
0
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...

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.