| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 350 人关注过本帖
标题:vb.net
只看楼主 加入收藏
xiexiaoqiang
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2006-2-26
收藏
 问题点数:0 回复次数:2 
vb.net

这道题我盯了几天了,实在是没有办法,哪位朋友帮我看一下,这里先谢过了......

Module modFree

#Region "clsShape"

Public Class clsShape

Private m_Area As Double

Private m_Sides As Integer

Public Sub New()

m_Area = 0.0

m_Sides = 0

End Sub

Public Sub New(ByVal Sides As Integer)

m_Sides = Sides

End Sub

Public Sub New(ByVal Area As Double)

m_Area = Area

End Sub

Public Sub New(ByVal Area As Double, ByVal Sides As Integer)

m_Area = Area

m_Sides = Sides

End Sub

Public Property Area() As Double

Get

Return m_Area

End Get

Set(ByVal Value As Double)

m_Area = Value

End Set

End Property

Public Property Sides() As Integer

Get

Return m_Sides

End Get

Set(ByVal Value As Integer)

m_Sides = Value

End Set

End Property

End Class

#End Region

#Region "clsTriangle"

Public Class clsTriangle

Inherits clsShape

Public Sub New()

MyBase.New(3)

End Sub

Public Sub New(ByVal Area As Double)

MyBase.New(Area, 3)

End Sub

Public Function CalculateArea(ByVal SideBase As Double, ByVal Height As Double, _ Optional ByVal AssignToArea As Boolean = False) As Double

Dim Area As Double = (SideBase * Height) / 2

If AssignToArea Then

Me.Area = Area

End If

Return Area

End Function

End Class

#End Region

Public Sub Main()

Dim objTriangle As New clsTriangle

Dim objShape As New clsShape

objTriangle.Area = -330

objTriangle.Sides = 5.5

objTriangle.CalculateArea(10.0, 2.5)

objShape.Area = 123

objShape.Sides = -2

objShape = CType(objShape, clsTriangle)

Console.WriteLine(TypeOf objTriangle Is clsShape)

Console.WriteLine(TypeOf objShape Is clsTriangle)

Console.WriteLine(objTriangle.Area)

End Sub

End Module

7.1 Please find the line of code from the procedure Main to cause run-time error.

Answer:

7.2 Please write the result output from the procedure Main.

Answer:

2006-05-23 13:58
xinfresh
Rank: 4
等 级:贵宾
威 望:13
帖 子:594
专家分:0
注 册:2006-1-13
收藏
得分:0 
这个里面有错误啊
AssignToArea没有声明

objTriangle.Sides = 5.5类型不一致

E-mail:xinfresh@QQ:383094053校内:http:///getuser.do?id=234719042
2006-05-23 14:11
xiexiaoqiang
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2006-2-26
收藏
得分:0 
求助
_ Optional ByVal AssignToArea As Boolean = False
这里不是AssignToArea的声明吗?
2006-05-23 16:53
快速回复:vb.net
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016309 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved