1、开放的开放的 Internet 传输协议传输协议Windows API.NET FrameworkGendPageClass370789603330748637198911542781Imports System.MathNamespace Geometry Public Module Module1 Sub Main()Dim tri As Triangle=New Triangle(2,3,4)Console.WriteLine(tri.ComputeArea()Console.WriteLine(Circle.Area(5)End Sub End Module Public Class
2、Triangle Dim m_a,m_b,m_c As Integer Public Sub New()empty constructor End Sub Public Sub New(a As Integer,b As Integer,c As Integer)m_a=a:m_b=b:m_c=c End Sub Public Function ComputeArea()As Double Dim s As Double=(m_a+m_b+m_c)/2 Return Sqrt(s*(s m_a)*(s m_b)*(s m_c)End Function End Class Public Clas
3、s Circle Public Shared Function Area(ByVal r As Double)As Double Return Pi*(r 2)End Function End ClassEnd NamespacePublic Sub Public Sub New()New()empty constructorEnd SubEnd SubPublic Sub Public Sub New(a As Integer,.New(a As Integer,.m_a=a:m_b=b:m_c=c m_a=a:m_b=b:m_c=cEnd SubEnd SubPublic Shared F
4、unction Public Shared Function Area(Area(ByValByVal r r As AsPublic ModulePublic Module Module1Module1Public ClassPublic Class TriangleTrianglePublic ClassPublic Class CircleCircleImportsImports System.MathSystem.MathDim Dim tritri As As Triangle=Triangle=New New Triangle(2,3,4)Triangle(2,3,4)Consol
5、e.WriteLine(tri.ComputeAreaConsole.WriteLine(tri.ComputeArea()()Dim Dim m_a,m_b,m_cm_a,m_b,m_c As IntegerAs IntegerDim Dim s s As As Double=(m_a+m_b+m_c)/2Double=(m_a+m_b+m_c)/2Return Return Sqrt(sSqrt(s *(s m_a)(s m_a)*(s m_b).(s m_b).NamespaceNamespace GeometryGeometryConsole.WriteLine(Circle.Area
6、(5)Console.WriteLine(Circle.Area(5)For I=1 To 10 for loopNext IFor(i=1;i11;i+)/for loopTryCatch ConditionWeCanHandle FinallyEnd TryfReRaise=FalseOn Error GoTo ErrHandlerGoTo CleanupErrHandler:if ConditionWeCanHandle ThenfReraise=Trueif fReraise Then err.Raise errTryCatch ConditionWeCanHandleFinallyEnd Try