无聊之余自制一个计算器,最开始的想法是,输入长度,然后监测文本框,同步输出结果,代码见下面。为何运行时后面的标签文本不响应?
尝试把text_change()代码注释掉然后随便写一点测试代码,发现text_changge()在编辑文本框的时候根本没有执行……
由于刚开始时学习,请大虾们不吝赐教!!
Public Class Frmmain
Dim linput As Single
Dim length As Single
Private Sub Frmmain_Load(sender As Object, e As EventArgs) Handles Me.Load
cbolorg.SelectedIndex = 0
cbolrlt.SelectedIndex = 2
End Sub
Private Sub Textl1_Change()
If IsNumeric(Me.Textl1.Text) = False Then
lblen.Text = "Err"
Exit Sub
End If
Select Case cbolorg.SelectedIndex
Case 0
Select Case cbolrlt.SelectedIndex
Case 0
lblen.Text = Textl1.Text
Case 1
lblen.Text = Val(Textl1.Text) / 12
Case 2
lblen.Text = Val(Textl1.Text) / 25.4
Case 3
lblen.Text = Val(Textl1.Text) / 25400
End Select
Case 1
Select Case cbolrlt.SelectedIndex
Case 0
lblen.Text = Val(Textl1.Text) * 12
Case 1
lblen.Text = Textl1.Text
Case 2
lblen.Text = Val(Textl1.Text) * 304.8
Case 3
lblen.Text = Val(Textl1.Text) * 0.3048
End Select
Case 2
Select Case cbolrlt.SelectedIndex
Case 0
lblen.Text = Val(Textl1.Text) / 12
Case 1
lblen.Text = Val(Textl1.Text) / 304.8
Case 2
lblen.Text = Textl1.Text
Case 3
lblen.Text = Val(Textl1.Text) / 1000
End Select
Case 3
Select Case cbolrlt.SelectedIndex
Case 0
lblen.Text = Val(Textl1.Text * 1000) / 308.4
Case 1
lblen.Text = Val(Textl1.Text * 1000) / 25.4
Case 2
lblen.Text = Val(Textl1.Text) * 1000
Case 3
lblen.Text = Textl1.Text
End Select
End Select
End Sub
End Class
尝试把text_change()代码注释掉然后随便写一点测试代码,发现text_changge()在编辑文本框的时候根本没有执行……
由于刚开始时学习,请大虾们不吝赐教!!
Public Class Frmmain
Dim linput As Single
Dim length As Single
Private Sub Frmmain_Load(sender As Object, e As EventArgs) Handles Me.Load
cbolorg.SelectedIndex = 0
cbolrlt.SelectedIndex = 2
End Sub
Private Sub Textl1_Change()
If IsNumeric(Me.Textl1.Text) = False Then
lblen.Text = "Err"
Exit Sub
End If
Select Case cbolorg.SelectedIndex
Case 0
Select Case cbolrlt.SelectedIndex
Case 0
lblen.Text = Textl1.Text
Case 1
lblen.Text = Val(Textl1.Text) / 12
Case 2
lblen.Text = Val(Textl1.Text) / 25.4
Case 3
lblen.Text = Val(Textl1.Text) / 25400
End Select
Case 1
Select Case cbolrlt.SelectedIndex
Case 0
lblen.Text = Val(Textl1.Text) * 12
Case 1
lblen.Text = Textl1.Text
Case 2
lblen.Text = Val(Textl1.Text) * 304.8
Case 3
lblen.Text = Val(Textl1.Text) * 0.3048
End Select
Case 2
Select Case cbolrlt.SelectedIndex
Case 0
lblen.Text = Val(Textl1.Text) / 12
Case 1
lblen.Text = Val(Textl1.Text) / 304.8
Case 2
lblen.Text = Textl1.Text
Case 3
lblen.Text = Val(Textl1.Text) / 1000
End Select
Case 3
Select Case cbolrlt.SelectedIndex
Case 0
lblen.Text = Val(Textl1.Text * 1000) / 308.4
Case 1
lblen.Text = Val(Textl1.Text * 1000) / 25.4
Case 2
lblen.Text = Val(Textl1.Text) * 1000
Case 3
lblen.Text = Textl1.Text
End Select
End Select
End Sub
End Class