写就行了阿
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
Dim x As Double
If e.KeyChar() = Microsoft.VisualBasic.ChrW(13) Then
If IsNumeric(TextBox1.Text) = True Then
x = TextBox1.Text
If x = 0 Then
TextBox2.Text = 100
ElseIf x > 0 Then
TextBox2.Text = x * x + 5
ElseIf x < 0 Then
TextBox2.Text = (x + 1) / (Math.Abs(x + 50) + 2)
End If
TextBox1.SelectAll()
Else
TextBox1.Text=""
MsgBox("请输入数字!")
End If
End If
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
Dim x As Double
If e.KeyChar() = Microsoft.VisualBasic.ChrW(13) Then
If IsNumeric(TextBox1.Text) = True Then
x = TextBox1.Text
If x = 0 Then
TextBox2.Text = 100
ElseIf x > 0 Then
TextBox2.Text = x * x + 5
ElseIf x < 0 Then
TextBox2.Text = (x + 1) / (Math.Abs(x + 50) + 2)
End If
Else
: MsgBox("请输入数字!")
★★-这里我还要加 TextBox1.Text="", 怎么写???
End If
End If
TextBox1.SelectAll()
End Sub
End Class