用VB解下面的题,简单的逻辑运算

1个回答

  • (1)

    Dim s as String

    s="abcde"

    If s.Substring(2, 1) = "C" Then

    MsgBox("Yes")

    Else

    MsgBox("No")

    End If

    (2)

    Dim x As Double

    Dim y As Double

    If x > 20 Then

    y = x * x + 3 * x + 2

    Else

    If x > 0 And x < 10 Then

    y = 1 / x + Math.Abs(x)

    Else

    If (x > 10 And x < 20) Or (x = 10 Or x = 20) Then

    y = Math.Sqrt(3 * x) - 2

    End If

    End If

    End If

    Select Case x

    Case x > 20

    y = x * x + 3 * x + 2

    Case (x > 10 And x < 20) Or (x = 10 Or x = 20)

    y = 1 / x + Math.Abs(x)

    Case x > 0 And x < 10

    y = Math.Sqrt(3 * x) - 2

    End Select