M
Martin Koenig
1. Textbox Number Format
Based on a combobox selection a textbox is filled as shown below:
Private Sub cmbAWS_Change()
Set rng = Range(cmbAWS.RowSource)
txtSFA.Text = rng(cmbAWS.ListIndex + 1)(1, 2)
End sub
The value that is supposed to be read in to the textbox from the
worksheet is sometimes a single decimal (5.1) or a two decimal
(5.10)number depending on the combobox selection, but the value
displayed is always a single decimal(5.1).
How can I get the textbox to display what is shown on the worksheet
(5.1 or 5.10)?
2. Deleting Value from Textbox
The user is to enter a value and based on the value entered in the
textbox txtDefectLength, it will use a dimension which had been
previously entered into the worksheet(rng3) to calculate percent of of
defect.
Private Sub txtDefectLength_Change()
Dim rng1 As Range
Set rng1 = Worksheets("WPQ").Range("CD24")
txtPrecentDefect.Value = (((txtDefectLength.Value) / (rng3 / 4))
* 100)
If txtPrecentDefect.Text <= 10 Then
txtResults.Value = "Passed"
Else: txtResults.Value = "Failes"
End If
End Sub
When entering a value into the textbox(txtDefectLength) it works fine,
but if the text is deleted to enter a different value I become the
error message "Type mismatch (Error 13)"
What can I do to stop this from happening?
Any help would be appreciated.
Kind Regards
Martin
Based on a combobox selection a textbox is filled as shown below:
Private Sub cmbAWS_Change()
Set rng = Range(cmbAWS.RowSource)
txtSFA.Text = rng(cmbAWS.ListIndex + 1)(1, 2)
End sub
The value that is supposed to be read in to the textbox from the
worksheet is sometimes a single decimal (5.1) or a two decimal
(5.10)number depending on the combobox selection, but the value
displayed is always a single decimal(5.1).
How can I get the textbox to display what is shown on the worksheet
(5.1 or 5.10)?
2. Deleting Value from Textbox
The user is to enter a value and based on the value entered in the
textbox txtDefectLength, it will use a dimension which had been
previously entered into the worksheet(rng3) to calculate percent of of
defect.
Private Sub txtDefectLength_Change()
Dim rng1 As Range
Set rng1 = Worksheets("WPQ").Range("CD24")
txtPrecentDefect.Value = (((txtDefectLength.Value) / (rng3 / 4))
* 100)
If txtPrecentDefect.Text <= 10 Then
txtResults.Value = "Passed"
Else: txtResults.Value = "Failes"
End If
End Sub
When entering a value into the textbox(txtDefectLength) it works fine,
but if the text is deleted to enter a different value I become the
error message "Type mismatch (Error 13)"
What can I do to stop this from happening?
Any help would be appreciated.
Kind Regards
Martin