Skip to content

Commit

Permalink
.net-vb-inherit-area-example-added
Browse files Browse the repository at this point in the history
  • Loading branch information
rajjitlai committed Oct 23, 2024
1 parent bc58123 commit 90a05e1
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
25 changes: 25 additions & 0 deletions dotNET/vbTheory/InheritArea/InheritArea.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.12.35323.107
MinimumVisualStudioVersion = 10.0.40219.1
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "InheritArea", "InheritArea.vbproj", "{45092605-64E0-4196-9352-2E15C128EE72}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{45092605-64E0-4196-9352-2E15C128EE72}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{45092605-64E0-4196-9352-2E15C128EE72}.Debug|Any CPU.Build.0 = Debug|Any CPU
{45092605-64E0-4196-9352-2E15C128EE72}.Release|Any CPU.ActiveCfg = Release|Any CPU
{45092605-64E0-4196-9352-2E15C128EE72}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E30C6DF2-6A25-4F71-AAB8-2BBBCF09DBDF}
EndGlobalSection
EndGlobal
9 changes: 9 additions & 0 deletions dotNET/vbTheory/InheritArea/InheritArea.vbproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<RootNamespace>InheritArea</RootNamespace>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

</Project>
35 changes: 35 additions & 0 deletions dotNET/vbTheory/InheritArea/Program.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Module Module1
Class Rectangle
Public Length As Integer
Public Width As Integer

Public Sub SetValues(len As Integer, wid As Integer)
Length = len
Width = wid
End Sub

Public Function CalculateArea() As Integer
Return Length * Width
End Function
End Class

Class Square
Inherits Rectangle

Public Function CalculateSquareArea() As Integer
Return Length * Length
End Function
End Class

Sub Main()
Dim rect As New Rectangle()
rect.SetValues(5, 10)
Console.WriteLine("Area of Rectangle: " & rect.CalculateArea())

Dim sqr As New Square()
sqr.Length = rect.Length
Console.WriteLine("Area of Square (using length from base): " & sqr.CalculateSquareArea())

Console.ReadLine()
End Sub
End Module

0 comments on commit 90a05e1

Please sign in to comment.