2 个小数结果以 VB 为单位


    If RadioButtonAC144.Checked = True Then
        TextBoxACScale.Text = TextBoxACReal.Text / 144
    ElseIf RadioButtonAC72.Checked = True Then
        TextBoxACScale.Text = TextBoxACReal.Text / 72
    ElseIf RadioButtonAC48.Checked = True Then
        TextBoxACScale.Text = TextBoxACReal.Text / 48
    ElseIf RadioButtonAC35.Checked = True Then
        TextBoxACScale.Text = TextBoxACReal.Text / 35
    ElseIf RadioButtonAC32.Checked = True Then
        TextBoxACScale.Text = TextBoxACReal.Text / 32
    ElseIf RadioButtonAC24.Checked = True Then
        TextBoxACScale.Text = TextBoxACReal.Text / 24
    End If

这是我的代码,我有几个与此类似的页面(选项卡),所以它是一个 PITA 来改变它,但如果这是唯一的方法,那就这样吧,但是我只需要显示在 TextBoxACScale.Text 中的结果最多显示 2 位小数。 此代码在单击计算按钮时实现。

Dim Divisor As Integer = 1
If RadioButtonAC144.Checked Then
    Divisor = 144
ElseIf RadioButtonAC72.Checked Then
    Divisor = 72
ElseIf RadioButtonAC48.Checked Then
    Divisor = 48
ElseIf RadioButtonAC35.Checked Then
    Divisor = 35
ElseIf RadioButtonAC32.Checked Then
    Divisor = 32
ElseIf RadioButtonAC24.Checked Then
    Divisor = 24
End If
TextBoxACScale.Text = (Convert.ToDecimal(TextBoxACReal.Text) / Divisor).ToString("F2")
If RadioButtonAC144.Checked = True Then
    TextBoxACScale.Text = Round(TextBoxACReal.Text / 144,2)
ElseIf RadioButtonAC72.Checked = True Then
    TextBoxACScale.Text = Round(TextBoxACReal.Text / 72,2)
ElseIf RadioButtonAC48.Checked = True Then
    TextBoxACScale.Text = Round(TextBoxACReal.Text / 48,2)
ElseIf RadioButtonAC35.Checked = True Then
    TextBoxACScale.Text = Round(TextBoxACReal.Text / 35,2)
ElseIf RadioButtonAC32.Checked = True Then
    TextBoxACScale.Text = Round(TextBoxACReal.Text / 32,2)
ElseIf RadioButtonAC24.Checked = True Then
    TextBoxACScale.Text = Round(TextBoxACReal.Text / 24,2)
End If

最新更新