473,388 Members | 1,417 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,388 software developers and data experts.

Converting string to Double?

J
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????

Oct 7 '07 #1
7 12111

"J" <No*****@NoEmail.comschreef in bericht
news:85**********************************@microsof t.com...
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????
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
Oct 7 '07 #2
Hi J

Have a look at

Double.Parse(...)

and

Double.TryParse(...)

HTH

Charles
"J" <No*****@NoEmail.comwrote in message
news:85**********************************@microsof t.com...
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????

Oct 7 '07 #3
"J" <No*****@NoEmail.comschrieb
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.
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

Oct 7 '07 #4
Jem
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
"Charles Law" <bl***@nowhere.comwrote in message
news:u$**************@TK2MSFTNGP04.phx.gbl...
Hi J

Have a look at

Double.Parse(...)

and

Double.TryParse(...)

HTH

Charles
"J" <No*****@NoEmail.comwrote in message
news:85**********************************@microsof t.com...
>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????

Oct 7 '07 #5
J,

Those things you can test in the way as Armin and Jaap wrote.

Just

Dim myDouble as Double = CDbl("12345")

Cor
Oct 7 '07 #6
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

Oct 8 '07 #7
Cor Ligthert[MVP] wrote:
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..?

--

(O)enone
Oct 8 '07 #8

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

Similar topics

5
by: matt melton | last post by:
Hi there, I am trying to write a method that accepts an array of any primitive type and will return the same array without copying memory as an array of bytes. ie. I'd like to be able to do...
4
by: Cyde Weys | last post by:
I'm currently working on converting a simulator program from Visual Basic 6.0 to Visual C++ .NET. I've figured out most of the stuff, but there's still one thing I haven't gotten to and I've never...
4
by: rainmaker1234 | last post by:
Its very simple in VC++. In the followeing code I have declared a String, and a double than I am taking the string and converting it into Double. getch() at the end is only to pause the screen so...
5
by: shang | last post by:
Hi! I am trying to find a function that converts a string into a double or a long double number. I found atod() but I don't know which library I have to include to use it. Could someone help me? ...
12
by: Frederik Vanderhaeghe | last post by:
Hi, I have a problem converting text to a double. Why doesn't the code work: If Not (txtdocbedrag.Text = "") Then Select Case ddlBedrag.SelectedIndex Case 0 Case 1
5
by: SMichal | last post by:
Hi, how can I parse string "? 20.000" to double ?
10
by: Ron | last post by:
I want to calculate the surface area of a sphere from an inputed radius with option strict on. I guess I am not converting something correctly. Here is what I am doing: I have a textbox...
3
by: nvx | last post by:
Hi, I'm looking for a simple way to convert a Double to a String exactly the .ToString() does, except these two differences: - the number of decimals is given (rounding is applied if necessary),...
25
by: Blasting Cap | last post by:
I keep getting errors that pop up when I am trying to convert an application from dotnet framework 1.1 to framework 2.0. The old project was saved in sourcesafe from Visual Studio 2003, and I have...
7
by: ma740988 | last post by:
Consider the equation (flight dynamics stuff): Yaw (Degrees) = Azimuth Angle(Radians) * 180 (Degrees) / 3.1415926535897932384626433832795 (Radians) There's a valid reason to use single...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
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...
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
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
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...
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...

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.