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

Recommended Answers

All 3 Replies

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.

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.