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_TextCha nged(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles tbPrice.TextCha nged
xPrice = System.Convert. ToDouble(tbPric e.Text)
End Sub
Where xPrice is a double. Any ideas? TIA
3 7232
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_TextCha nged(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles tbPrice.TextCha nged
xPrice = System.Convert. ToDouble(tbPric e.Text)
End Sub
Where xPrice is a double. Any ideas? TIA
http://iheartdotnet.bl ogspot.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?
Think I found a solution, use numbericupdown control! I never knew it existed :P
Plater 7,872
Recognized Expert Expert
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.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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 (perhaps mistakenly) that the
purpose of a void pointer was to cast into a legitimate date type. Is
this wrong? Why, and what is considered to be correct form?
|
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 following:
(TextBox)UserPrefix=(TextBox)e.Item.Cells.Controls;
string strUserPrefix=UserPrefix.Text;
I keep getting the following error and I don't know why because I have
declared the UserPrefix as a textbox using "protected...
|
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 cast the Control parameter, DropCtrl, to a TextBox
object? The underlying control is in fact a textbox which I wish to
redraw given the X and Y parameters above. In Java, you could simply
declare a TextBox reference and assign it to the Control...
|
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 )
{
Value = ((B)lhs)->Value + ((B)rhs)->Value;
|
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 MovePoint(double,double);
}
}
| |
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 structure; the map's
key is also a double. The issue seemed to be occuring in the map's
default comparison function so I implemented my own comparison
operator, but then the error continued happening in my new fxn.
Strangely, casting the double I...
|
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 'object' to 'double'. An explicit
conversion exists (are you missing a cast?)
|
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 type conversion and the actual bits change.
if you say (float) 3.0 it is a type disambiguation,and the compiler
can plant the correct bits in the first place.some people say that
|
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" variable,
which of the following lines are correct:
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
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();...
|
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...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |