P
Patrick Simonds
I have a stumbling block in my code below.
If I do not assign a value to ComboBox11 (and the default value I want is 0)
then I get a type mismatch error when I start to enter a number in TextBox2.
If I do assign a value to ComboBox11 (using .ComboBox11.Value = "0") then
everything works with the notable exception that I when I use the dropdown
on the ComboBox to select one of my other choices (0, .5, 1) I can not
change the value. It remains at 0 no mater what I do.
Anyone have any thoughts on this?
Sub TotalHours1()
Dim bTest1 As Boolean
Dim bTest2 As Boolean
Dim bTest3 As Boolean
Dim dblElapsed
With UserForm1
.ComboBox11.Value = "0"
If IsNumeric(.TextBox1.Text) And _
IsNumeric(.TextBox2.Text) Then
dblElapsed = (CDbl(.TextBox2.Text) - CDbl(.TextBox1.Text) -
CDbl(.ComboBox11.Text))
.TextBox3.Value = Format(dblElapsed, "#0.00")
If .ComboBox1.Value = "" Then GoTo EnterCode
GoTo EndMacro
EnterCode:
.ComboBox1.Value = "01"
Else
'MsgBox "There is an invalid time"
End If
GoTo EndMacro
ClearBox:
UserForm1.TextBox1.Value = Format("", "")
UserForm1.TextBox2.Value = Format("", "")
UserForm1.TextBox3.Value = Format("", "")
EndMacro:
End With
End Sub
If I do not assign a value to ComboBox11 (and the default value I want is 0)
then I get a type mismatch error when I start to enter a number in TextBox2.
If I do assign a value to ComboBox11 (using .ComboBox11.Value = "0") then
everything works with the notable exception that I when I use the dropdown
on the ComboBox to select one of my other choices (0, .5, 1) I can not
change the value. It remains at 0 no mater what I do.
Anyone have any thoughts on this?
Sub TotalHours1()
Dim bTest1 As Boolean
Dim bTest2 As Boolean
Dim bTest3 As Boolean
Dim dblElapsed
With UserForm1
.ComboBox11.Value = "0"
If IsNumeric(.TextBox1.Text) And _
IsNumeric(.TextBox2.Text) Then
dblElapsed = (CDbl(.TextBox2.Text) - CDbl(.TextBox1.Text) -
CDbl(.ComboBox11.Text))
.TextBox3.Value = Format(dblElapsed, "#0.00")
If .ComboBox1.Value = "" Then GoTo EnterCode
GoTo EndMacro
EnterCode:
.ComboBox1.Value = "01"
Else
'MsgBox "There is an invalid time"
End If
GoTo EndMacro
ClearBox:
UserForm1.TextBox1.Value = Format("", "")
UserForm1.TextBox2.Value = Format("", "")
UserForm1.TextBox3.Value = Format("", "")
EndMacro:
End With
End Sub