1 Replies - 345 Views - Last Post: 19 January 2013 - 03:51 PM Rate Topic: -----

#1 dlholtry  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 28-November 12

Adding key words Try, Catch and Finally to my Code

Posted 19 January 2013 - 03:36 PM

I need to include the key words Try, catch, and Finally. The code must show the correct answer or if there is an error the code must show an error code. I am not sure where to add the key words to make this function correctly.

Module Module1

    Sub Main()
        Dim side_of_cube, volume_ofcube As Double
        Console.Write("Enter value of side of cube: ")
        side_of_cube = Double.Parse(Console.ReadLine())
        volume_ofcube = side_of_cube * side_of_cube * side_of_cube
        Console.WriteLine("Value of volume of cube: " & volume_ofcube)
        Console.WriteLine()
        Shell("cmd /c pause", AppWinStyle.NormalFocus, True)
    End Sub

End Module

My guess is:
Sub Main()
        Dim side_of_cube, volume_ofcube As Double
        Console.Write("Enter value of side of cube: ")
        side_of_cube = Double.Parse(Console.ReadLine())
        Try
        volume_ofcube = side_of_cube * side_of_cube * side_of_cube
        Catch volume_ofcube
        Console.WriteLine("Value of volume of cube: " & volume_ofcube)
        Finally
        Console.WriteLine()
        Shell("cmd /c pause", AppWinStyle.NormalFocus, True)
    End Sub

End Module

This post has been edited by Atli: 19 January 2013 - 03:37 PM
Reason for edit:: Use [code] tags when posting code.


Is This A Good Question/Topic? 0
  • +

Replies To: Adding key words Try, Catch and Finally to my Code

#2 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5436
  • View blog
  • Posts: 11,656
  • Joined: 02-June 10

Re: Adding key words Try, Catch and Finally to my Code

Posted 19 January 2013 - 03:51 PM

MSDN page on Try...Catch...Finaly for VB.net
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1