Click here to Skip to main content
13,089,943 members (48,480 online)
Rate this:
Please Sign up or sign in to vote.
See more:
i have been analysing a code in that a double value is being changed to string and is split and then stored into database.

ex:dim a as double=123.23
dim b() as string

this can be done like this aslo
dim a as double=123.23
dim b as string

can anyone plz help me find what is the use of split() in this case.
Posted 16-Sep-12 17:06pm
Sergey Alexandrovich Kryukov 16-Sep-12 23:51pm
First, what's the problem? did you simply read the MSDN help on it? -- would be too trivial.
Second, why would you use double.ToString? Chances are, you don't need it. It's always good to explain your goals, to get better answers.
Member 8953399 17-Sep-12 0:51am
in my application values are stored in database by conversion of double value to string.if double can be directly changed into string using tostring() then why split() is used.i want the usage of split used here.
b = a.ToString().Split("."C)

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1


see this sample:
Dim a As Double = 123.23
Dim b As String() = Nothing
b = a.ToString().Split("."C)
Dim part1 As String = b(0)
Dim part2 As String = b(1)
MessageBox.Show(part1 + "  " + part2)

Basically in this case, split separates the part before and after the period, so that in b(0) you have "123" and in b(1) you have "23". Please take care of regional settings where 123.23 may be displayed as 123,23 (e.g. this is the case in Germany).
Member 8953399 17-Sep-12 6:42am
plz give the usage of split() here.
JF2015 17-Sep-12 6:47am
It is just to separate the part before and after the period.
Member 8953399 17-Sep-12 6:50am
this conversion of double to string can be done using tostring().but still why we require split().plz help
JF2015 17-Sep-12 7:31am
You don't need it. It may just be used if you want to have two separate strings. One before and one after the period.
Member 8953399 17-Sep-12 12:38pm
plz dont mind bcz the code am analysing this code and in that split is used.

Dim avgBVsplit(2) As String
avgBVsplit = SumPC.ToString().Split(".")
If avgBVsplit.Count = 2 Then
If avgBVsplit(1).Length > 2 Then
frmRMM.tslPC.Text = "PC(Sum) : " + avgBVsplit(0) + "." + avgBVsplit(1).Substring(0, 2)
frmRMM.tslPC.Text = "PC(Sum) : " + SumPC.ToString()
End If
frmRMM.tslPC.Text = "PC(Sum) : " + SumPC.ToString()
End If

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.170813.1 | Last Updated 16 Sep 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100