谢谢大家。我现在有很多函数。我将修补转换我的VB。NET代码。我稍后会发布结果。
VB。网络代码
- ' This handles any non-integer input and rounds the user's input up to the nearest vDenominator
- ' In this case we use 1/16" and it remember it rounds up, not down.
- Public Function RoundFraction(ByVal x As Double, ByVal vDenominator As Integer) As Double
- If (x - Int(x)) * vDenominator <> Int((x - Int(x)) * vDenominator) Then
- x = (Int((x - Int(x)) * vDenominator) + 1) / vDenominator + Int(x)
- End If
- Return x
- End Function
我这样称呼它:
- RoundFraction(4.4231, 16)
结果是4.4375。这纠正了当用户输入一个奇怪的维度,该维度至少足够接近他们想要的。 |