我用vb写了一个计算长方形~正方形或三角形面积的程序~代码如下~怎样修改啊~Private Sub Command1_Click()Dim a As StringDim h,l,s As Singlea = InputBox("请输入形状(只限于长方形~正方形或三角形)","请输入")If (a = "长方形" Or "正方形") Thenh = InputBox("请输入宽","请输入")l = InputBox("请输入长","请输入")s = h * lPrint a; "的面积为"; sElseh = InputBox("请输入的高","请输入")l = InputBox("请输入的底","请输入")s = h * l / 2Print a; "的面积为"; sEnd IfMsgBox "计算完毕",,"提示"End Sub

问题描述:

我用vb写了一个计算长方形~正方形或三角形面积的程序~
代码如下~怎样修改啊~
Private Sub Command1_Click()
Dim a As String
Dim h,l,s As Single
a = InputBox("请输入形状(只限于长方形~正方形或三角形)","请输入")
If (a = "长方形" Or "正方形") 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 Sub