Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim x As Single, y As Single
        x = InputBox("请输入x的值")
        If x >= 0 Then y = x ^ 2 - 1 Else y = 2 * x ^ 3 - x + 1
        Debug.Print(y)
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim x As Single, y As Single
        x = InputBox("请输入x的值")
        If x >= 0 Then
            y = x ^ 2 - 1
        Else
            y = 2 * x ^ 3 - x + 1
        End If
        Debug.Print(y)
    End Sub
End Class
