Link to home
Start Free TrialLog in
Avatar of Johnny
JohnnyFlag for United States of America

asked on

how to not have 9.0 (need to display 9) but have 9.3 display if present(vb.net-2008-windows form)

i have a display problem i want to display a number as the whole number and if a #.0 is present display it as # no decimal but if 9.3 then display #.3

code below prints 9.0 now and not 9 (bare in mind again i need to display 9.3 if present)

thanks in advance for any code or help you mat provide
ps: if i didnt explain this right please ask me ill try better

Result_Box.AppendText("PackageDimensions.Length: " & item.ItemAttributes.PackageDimensions.Length.Value & vbCrLf)
                Dim b_Length As Decimal = FormatNumber(CStr(CDbl(((item.ItemAttributes.PackageDimensions.Length.Value) / 100))), 2)
                Result_Box.AppendText("PackageDimensions.Length - inches: " & b_Length.ToString & vbCrLf)

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Alexandre Simões
Alexandre Simões
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
As you only want 1 decimal place it should be: 0.#
Try this

Dim test as Double = 9.0

If Integer.Parse(test.tostring.split(".")(1)) > 0 Then
   'the value needs the decimal point
Else
   'value can be converted to integer
End if
Avatar of Johnny

ASKER

thx ever so much
Avatar of Johnny

ASKER

AlexCode: was simpler CodeCruiser: thx