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个小数位。单击计算按钮时会实现此代码。
答案 0 :(得分: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")
答案 1 :(得分:0)
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