Seperating numbers after decimal digit

  • Thread starter Thread starter Salim
  • Start date Start date
S

Salim

Hi guys,

seems very simple solution,but can't solve.

all i want is to seperate the numbers after decimal point in compact framework
e.g. dim x as double = 0.000623
dim y as double
dim z as double

all i want is y = 000623 and z = 0

Regards
Salim
 
Are you looking for this??

Dim x As Double = 0.000623
Dim y As Double
Dim z As Double

MessageBox.Show(Split(x.ToString(), ",")(0) & " " &
Split(x.ToString(), ",")(1))

You have to view your decimal symbol in regional settings. In Spanish
properties
it is ",". When you convert to String one Double the point (".") is replaced
by your
decimal symbol.

Regards.
 
One of many ways:

Dim x As Double = 15.000623
Dim y1 As String
Dim z1 As String
Dim x1 As String = x.ToString()
Dim i As Int32 = x1.IndexOf("."c)
y1 = x1.Substring(0, i)
z1 = x1.Substring(i + 1)

If you really want them as doubles, like you say in your post, then just
Convert.ToDouble each string

If you want to cater for commas (,) as well use:
System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator

Cheers
Daniel
 
that worked thanks guys

Regards
Salim

Daniel Moth said:
One of many ways:

Dim x As Double = 15.000623
Dim y1 As String
Dim z1 As String
Dim x1 As String = x.ToString()
Dim i As Int32 = x1.IndexOf("."c)
y1 = x1.Substring(0, i)
z1 = x1.Substring(i + 1)

If you really want them as doubles, like you say in your post, then just
Convert.ToDouble each string

If you want to cater for commas (,) as well use:
System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator

Cheers
Daniel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top