Hi
I'm just trying to convert a small program that was written in VB6 to
VB.Net.
I'm stumbling at the first hurdle!
In VB I could do the following (ensuring that the textbox only contained
numeric input of course)...
Dim MyNumber as Double
MyNumber = CDbl(MyNumericTextString.text)
and that would work fine.
Vb.Net won't let me do the above. What do I use instead????
Armin Zingler - 07 Oct 2007 11:26 GMT
> Hi
>
[quoted text clipped - 12 lines]
>
> Vb.Net won't let me do the above.
Why? Error message? What is the value of MyNumericTextString.text? What is
the current culture setting? The input format must be compliant to the
current culture settings for numeric inputs.
> What do I use instead????
If MyNumericTextString is a textbox containing "12345", it does work here.
Armin
Jaap Bos - 07 Oct 2007 11:42 GMT
> Hi
>
[quoted text clipped - 12 lines]
>
> Vb.Net won't let me do the above. What do I use instead????
Strange, your example works without a problem for me (VB Express 2005). I
assume that .text is an email-typo, should be .Text, but normally the
program would make the change automatically if you type .text.
Precisely "what" does not work when you use your program?
Jaap
Charles Law - 07 Oct 2007 11:52 GMT
Hi J
Have a look at
Double.Parse(...)
and
Double.TryParse(...)
HTH
Charles
> Hi
>
[quoted text clipped - 12 lines]
>
> Vb.Net won't let me do the above. What do I use instead????
Jem - 07 Oct 2007 15:43 GMT
Ahhh.. On further investigation it only errors if the textbox contains a
null string, and obviously it can't convert that to a double. This was
obviously a fault that was in the original program as well. I've error
trapped it now and everything seems fine, sorry for that.
J
> Hi J
>
[quoted text clipped - 26 lines]
>>
>> Vb.Net won't let me do the above. What do I use instead????
Cor Ligthert[MVP] - 07 Oct 2007 16:00 GMT
Charles,
Hi glad to see you, had to think lately about you, not for the last because
I have send some samples of that JScript from you.
Why not use that so nice CDbl from VB.Net, it is something I really miss in
C#.
(I can make it of course but that is for me not documentative)
Cor
Charles Law - 08 Oct 2007 12:44 GMT
Hi Cor
I've been off in the wilderness, updating a VB6 application for a client,
for much longer than I would have liked. But I'm back at last, so I'm
revisiting some of my old haunts.
Good to hear from you.
Charles
> Charles,
>
[quoted text clipped - 7 lines]
>
> Cor
Cor Ligthert[MVP] - 08 Oct 2007 18:17 GMT
Charles,
Now I see your message, it was not that javascrip.
I was explaining somebody about the Queue class. Now I hear that you are
back in civilisation that quarter felt in the right place.
(Although we don't have a quarter anymore here in Holland).
:-)
Cor
(O)enone - 08 Oct 2007 19:16 GMT
> Why not use that so nice CDbl from VB.Net, it is something I really
> miss in C#.
You could always add a reference to Microsoft.VisualBasic from your C#
project, then you can use all the nice ol' VB functions such as this in your
C# project without needing to rewrite them..?

Signature
(O)enone
Cor Ligthert[MVP] - 07 Oct 2007 15:58 GMT
J,
Those things you can test in the way as Armin and Jaap wrote.
Just
Dim myDouble as Double = CDbl("12345")
Cor