Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Switching the data type from Double to Decimal has solved the issue! I wrestled with all these formatting methods only to find more restriction or unwanted behavior. Thanks to all for their input. My updated code is below.</p> <pre><code>Private Function GetLength1(ByVal decLengthUnit1 As Decimal) As Decimal Dim decResult1 As Decimal If cboUnitType.SelectedItem = "Length" Then ' converts centimeter to... If cbo1.SelectedItem = "Centimeter" Then If cbo2.SelectedItem = "Kilometer" Then decResult1 = (decLengthUnit1 * 0.0001) ElseIf cbo2.SelectedItem = "Meter" Then decResult1 = (decLengthUnit1 * 0.01) ElseIf cbo2.SelectedItem = "Centimeter" Then decResult1 = txtUnit1.Text ElseIf cbo2.SelectedItem = "Millimeter" Then decResult1 = (decLengthUnit1 * 10) ElseIf cbo2.SelectedItem = "Mile" Then decResult1 = (decLengthUnit1 * 0.000006214) ElseIf cbo2.SelectedItem = "Yard" Then decResult1 = (decLengthUnit1 * 0.010936133) ElseIf cbo2.SelectedItem = "Foot" Then decResult1 = (decLengthUnit1 * 0.032808399) ElseIf cbo2.SelectedItem = "Inch" Then decResult1 = (decLengthUnit1 * 0.393700787) End If End If Return decResult1 End Function Private Sub txtUnit1_TextChanged(sender As Object, e As EventArgs) Handles txtUnit1.TextChanged If suppressTextBox1TextChanged = False Then Decimal.TryParse(txtUnit1.Text, decUnit1) ' if String.Empty If txtUnit1.Text = "" Then txtUnit2.Text = "" Else ' trigger the function suppressTextBox2TextChanged = True txtUnit2.Text = GetLength1(decUnit1) suppressTextBox2TextChanged = False End If End If End Sub </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload