12,353,366 members (69,307 online)
Rate this:
See more:
Hello everyone,

I need to display a decimal number in two different label

example

45.36

label 1 45
label 2 36

Posted 26-Feb-13 23:57pm

Rate this:

## Solution 1

Well there are numerous ways:
Here is one
```Sub SplitDecimal(ByVal number As Decimal, ByRef wholePart As Decimal, _
ByRef fractionalPart As Decimal)
wholePart = Math.Truncate(number)
fractionalPart = number - wholePart
End Sub```

=OR=
```string sample = "235.14587";
string[] output = sample.Split(".".ToCharArray());
int before = output[0].Length;
int after = output[1].Length;```

Good luck,
OI
v2
Rate this:

## Solution 2

```To get first part, you can do the following:
Decimal.floor(45.36)
Math.Truncate(45.36)

to get second part,

Dim fracPart As Decimal
wholePart = Math.Truncate(number1)
fractPart = number1 - wholePart
'where number1 will store 45.31

you can also split:

Dim num1 As String = 532.016 'if this is integer, convert to string
Dim res() As String
res = Split(num1, ".")
'res(0), res(1) will give you separate values
```
Orcun Iyigun 27-Feb-13 6:22am

Well how is your solution different than mine?

Top Experts
Last 24hrsThis month
 OriginalGriff 434 Member 12599256 258 Maciej Los 220 Sergey Alexandrovich Kryukov 210 Dave Kreskowiak 205
 OriginalGriff 9,324 Sergey Alexandrovich Kryukov 6,399 Dave Kreskowiak 3,214 ppolymorphe 2,371 Karthik Bangalore 2,266