Results 1 to 7 of 7

Thread: Coding Help

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2003
    Posts
    23

    Question Coding Help

    Good Evening,
    I caused great confusion in my class by trying to ask questions about coding so I am turning to the professionals to help me write this code.

    I must create a sub method called InTwo which accepts two integer arguments passed by reference. The code should use 2 input boxes to input the 2 integers from the user.

    This is what I put please help me to figure it correctly.

    Private Sub InTwo(ByRef intA As Integer, By Ref intB As Integer)

    intA = InputBox("Enter the Hours:", {})
    intB = InputBox("Enter the Minutes:", {})
    End Sub


    Part 2 says I must create a function method, which takes two integers, that represent time in hours and minutes. Call the function MinutesIn. The function should return the total time in minutes.

    Here is what I put:

    Private Function MinutesIn(ByVal intHours As Integer, _
    ByVal intMinutes As Integer)
    As Integer (why do you have to put that again after you already declared that inside the parenthesis?)

    Dim intTotalMinutes As Integer = MinutesIn ({}, {})
    intTotalMinutes = (intHours *60) + intMinutes
    Return intTotalMinutes
    End Function


    Part 3 I have no clue on.... We are supposed to create a second function method TimeDifferenceInMins, with 4 ByVal arguments and an integer return result. The function accepts two times in hours and minutes and returns the difference between them in minutes. Use the InTwo and MinutesIn procedures your just wrote.

    Any comments or suggestions are greatly appreciated.

    JAZ

  2. #2
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474

    Re: Coding Help

    Originally posted by keanez


    Private Function MinutesIn(ByVal intHours As Integer, _
    ByVal intMinutes As Integer)
    As Integer (why do you have to put that again after you already declared that inside the parenthesis?)
    This shows the type of your function. What you put in parenthesis is the type of arguments you pass to your function but what the function returns may be totally a different type. Is it clear enugh?
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Sep 2003
    Posts
    23
    Thank you. That part makes sense. Do you have any idea how I can go about part 3??? Thank you in advance for your response.

    JAZ

  4. #4
    Lively Member
    Join Date
    Sep 2003
    Location
    Chicago, IL
    Posts
    64
    Check out attached...
    Attached Files Attached Files
    Mike Stammer

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Sep 2003
    Posts
    23

    Wink Thank you

    Thank you very much for your help. I really appreciate your tiem and effort. May I please ask one more question, what is TRY? We have not used that, but it appears to be very helpful. Thank you again for your help as I am trying to learn this languauge and when I ask questions sometimes I cause a great confusion in the class.

    JAZ

  6. #6
    Lively Member
    Join Date
    Sep 2003
    Location
    Chicago, IL
    Posts
    64
    Try is used for error handling

    try

    catch

    end try


    what it does is try the code and if an error happens, the catch block is executed. this way you can trap errors and use it to do things so your program does not crash. Check it out in the documentation. You should use them around EVERY line of code (except variable declarations).
    Mike Stammer

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Sep 2003
    Posts
    23
    Thank you, Mike. You have been very helpful!!! Have a Great Day!!!

    JAZ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width