VB中类的继承和多态

来源:百度知道 编辑:UC知道 时间:2024/09/27 12:09:56
老师出了一道VB题目 要求很简单,就是:

定义一个display函数,通过重载分别实现圆、矩形、三角形的面积的计算

没有太明白...求一个编写方法
最好能有完整清晰的写法

谢谢谢谢咯!

大概写个过程,可能有效错误,你自己改下吧
有问题再联系
public function display()

if DropDownList1.text="三角形"then

Dim a As Single, b As Single, c As Single
Dim d As Single
Dim e As Single, f As Single

a = Text1.Text
b = Text2.Text
c = Text3.Text
d = (a * a + b * b - c * c) / (2 * a * b)
If (a + b) <= c Or (a + c) <= b Or (b + c) <= a Then

MsgBox "三个边构不成三角形!", 48

Else
e = Sqr(1 - d * d)
f = a * b * e * 0.5
Text4.Text = Str(f)
End if
elseif DropDownList1.text="圆" then

Dim a!
a = 3.14
Dim b!
b=text1.text
Dim c!

c = 2 * a * b
Text2.Print c

Private Sub Text1_LostFocus()
If Not IsNumeric(Text1) Then
MsgBox "有非数字字符错误 "
Text1.Text =
Text1.SetFocus
End If

end if
End Sub

VB?
VB.net?
函数重载 只要参数不一致就可以了
比如圆形