0

hi guys i have designed software to read data from scales everything so far is so good except (yes theres always an except) part of my data arrives as 899 which is supposed to be 8.99 how can i converty this data to show 8.99 thankyou
stephen

2
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by stephen lowry
0

If it is always .xx then divide by 100.

Dim num As Decimal = 899
        Dim s As String = CStr(num)
        If s.IndexOf(".") < 0 Then
            TextBox1.Text = (num / 100D).ToString
        End If

As shown 8.99 would be put in the text box.
But if num = 899.1 then 899.1 would be put in the textbox.
Problem is 899.0 will be returned as 8.99 because the conversion to string removes the .0 so no dot is in the string.

0

If it is always .xx then divide by 100.

Dim num As Decimal = 899
        Dim s As String = CStr(num)
        If s.IndexOf(".") < 0 Then
            TextBox1.Text = (num / 100D).ToString
        End If

As shown 8.99 would be put in the text box.
But if num = 899.1 then 899.1 would be put in the textbox.
Problem is 899.0 will be returned as 8.99 because the conversion to string removes the .0 so no dot is in the string.

thanx wayne my main problem is that it may not always be 899 as it is scales the data is continuly changing (any ideas) thanx again
stephen

0

thanx again i just noticed something in you code /100 and it worked fine something so simple i overlooked
cheers

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.