Jump to content
Xtreme .Net Talk

JynxRD

Members
  • Posts

    2
  • Joined

  • Last visited

About JynxRD

  • Birthday 01/06/1980

JynxRD's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. 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
  2. I'm trying to learn VB .NET from some books and the web. I like to do the practice programs so I'm not just "reading" but "doing" what I'm learning, (or trying to learn). I'm stuck on 2 of them. I'll just post this one for now. I can write it (sort of) just using a bunch of nested if statements and so on however a friend of mine told me that's not exactly the way there wanting it done here per the instructions. So I'm sort of stuck and just need to see how it should look to satisfy the instructions.
×
×
  • Create New...