我用vb写了一个计算长方形~正方形或三角形面积的程序~

1个回答

  • 判断写错,改完的:

    Private Sub Command1_Click()

    Dim a As String

    Dim h,l,s As Single

    a = InputBox("请输入形状(只限于长方形~正方形或三角形)","请输入")

    If (a = "长方形" Or a = "正方形") Then

    h = InputBox("请输入宽","请输入")

    l = InputBox("请输入长","请输入")

    s = h * l

    Print a; "的面积为"; s

    Else

    h = InputBox("请输入的高","请输入")

    l = InputBox("请输入的底","请输入")

    s = h * l / 2

    Print a; "的面积为"; s

    End If

    MsgBox "计算完毕",,"提示"

    End Su