我用vb写了一个计算长方形~正方形或三角形面积的程序~代码如下~怎样修改啊~Private Sub Command1_Click()Dim a As StringDim h,l,s As Singlea = InputBox("请输入形状(只限于长方形~正方形或三角形)","请输
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/14 21:44:45
我用vb写了一个计算长方形~正方形或三角形面积的程序~代码如下~怎样修改啊~Private Sub Command1_Click()Dim a As StringDim h,l,s As Singlea = InputBox("请输入形状(只限于长方形~正方形或三角形)","请输
我用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
我用vb写了一个计算长方形~正方形或三角形面积的程序~代码如下~怎样修改啊~Private Sub Command1_Click()Dim a As StringDim h,l,s As Singlea = InputBox("请输入形状(只限于长方形~正方形或三角形)","请输
判断写错,改完的:
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 Sub