0
    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

This is my code, I have several pages(tabs) similar to this, so it's a PITA to change it all up but if it's the only way then so be it, however I just need the result that is showing up in TextBoxACScale.Text to show up to only 2 decimal places. This code is implemented when clicking a calculate button.

Michael
  • 1
  • 4
  • http://stackoverflow.com/questions/5168592/force-a-string-to-2-decimal-places VB.net and C# are the same. using String.Format – Russel Yang Apr 01 '14 at 00:17
  • You cannot divide text with integers. You have to convert the text into a number, do the division and then convert back. – John Alexiou Apr 01 '14 at 00:51
  • Everything functions now. I changed the rest of it. As a heads up the division with the text and such was working fine. – Michael Apr 01 '14 at 01:24

2 Answers2

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")
Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
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
King of kings
  • 695
  • 2
  • 6
  • 21