12,885,784 members (37,627 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 375 ppolymorphe 145 Maciej Los 140 CHill60 135 Jochen Arndt 100
 OriginalGriff 4,247 CHill60 2,513 Karthik Bangalore 2,436 Jochen Arndt 2,173 ppolymorphe 1,985