Here is what I have now. I'm having issues however. when I choose case 1 it works just fine. But if I choose case 2 it doesnt give my results. The If Not Object.Reference(B, Nothing) portion doesnt seem to work. It will ask the Case 2 questions but instead give me Case 1 results. I'd also like to figure out how to do a Case "r" if Readline is "r" and a Case "b" if Readline is "b"
Module Module1
Structure Rectangle
Private e As Boolean
Shared ReadOnly Property Empty() As Rectangle
Get
Empty = New Rectangle
Empty.e = True
End Get
End Property
Public ReadOnly Property isEmpty() As Boolean
Get
Return Me.e
End Get
End Property
Dim X
Dim Y
End Structure
Structure Box
Private e As Boolean
Shared ReadOnly Property Empty() As Box
Get
Empty = New Box
Empty.e = True
End Get
End Property
Public ReadOnly Property isEmpty() As Boolean
Get
Return Me.e
End Get
End Property
Dim X
Dim Y
Dim Z
End Structure
Sub Main()
'Bit different solution
Dim R As Rectangle = Rectangle.Empty, B As Box = Box.Empty
'INPUT
Console.Write("Would you like to create a Rectangle or a Box (r or b): ")
Select Case CInt(Console.ReadLine)
Case 1
R = New Rectangle
Console.Write("Please enter the Length: ")
R.X = CInt(Console.ReadLine)
Console.Write("Please enter the Width : ")
R.Y = CInt(Console.ReadLine)
Case 2
B = New Box
Console.Write("Please enter the Length: ")
B.X = CInt(Console.ReadLine)
Console.Write("Please enter the Width: ")
B.Y = CInt(Console.ReadLine)
Console.Write("Please enter the Height: ")
B.Z = CInt(Console.ReadLine)
End Select
'OUTPUT
Console.ForegroundColor = ConsoleColor.Green
Console.Write("Description of ")
If (B.ToString.Equals(String.Empty) = True) Then 'Describe Rectangle
Console.WriteLine("Rectangle:")
Console.WriteLine("Volume = {0:F}", R.X * R.Y)
Else 'describe Box
Console.WriteLine("Box:")
Console.WriteLine("Area = {0:F}", B.X * B.Y * B.Z)
End If
Console.ForegroundColor = ConsoleColor.White
Console.WriteLine("Press escape to exit")
Do : Loop Until Console.ReadKey().Key = ConsoleKey.Escape
End Sub
End Module