 |
| VB.NET General VB.NET discussions for issues that don't fall into other VB.NET forums. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the VB.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

February 15th, 2006, 09:18 AM
|
|
Authorized User
|
|
Join Date: Sep 2004
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Testing and debugging
Hi there everybody,
I was wondering if anyone could tell me what the answer to this question is......? I have been battling for ages and just can't work it out....a,b,c,d or e?
Dim I1 As Integer
Dim D1 As Double
Dim dte As Date
Try
dte = #4/1/2002#
I1 = dte.AddSeconds(-0.75).Day
D1 = I1 / (I1 - 1)
Exit Try
I1 = I1 * 2
Catch
I1 = 1000
Finally
Debug.WriteLine("I1 = " & I1)
End Try
What is the output from this code sample?
a. I1 = 62
b. I1 = 2
c. I1 = 1000
d. I1 = 31
e. No output will be generated by this code sample.
|
|

February 15th, 2006, 10:18 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Why don't you try it out in a small sample application??
Then you'd know it in a few seconds....
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|

February 15th, 2006, 11:18 AM
|
|
Authorized User
|
|
Join Date: Sep 2004
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi there,
I unfortunately am at work and don't have visual studio avaliable and really need to know before I head home.Would you mind letting me know ? Would be very much appreciated.
Regards
|
|

February 15th, 2006, 11:45 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
I hate giving away quiz answers, so I won't do that here.
However, this one shouldn't be too hard to find out.
What do you get when you subtract less than a second from a date with a time set at midnight? If you answer that question, you know what the first two lines of the Try block result in. From that point, it's just a matter of calculating with this value, and see where you end up.
P.S. You don't need Visual Studio. You can do this with the command line compiler from the SDK as well....
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|

February 15th, 2006, 12:01 PM
|
|
Authorized User
|
|
Join Date: Sep 2004
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Just can't seem to get it.....
Well, thanks for your help anyway Imar.
Regards
Brett
|
|

February 15th, 2006, 12:30 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
What's the date and time one second before April 1?
That's 31 March. Then .Day of that date returns the number 31
From that point, the rest should be easy. 31 / (31-1) is a little bit more than 1. However, the net result of that doesn't really matter as it doesn't influence I1 anymore.....
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|

February 15th, 2006, 12:53 PM
|
|
Authorized User
|
|
Join Date: Sep 2004
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Aaah, ok...so the answer is e ?
Excellent thanks so much.
Kind regards
Brett
|
|

February 15th, 2006, 12:59 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
I never said it was e. I said the outcome of the division didn't play a role in the final answer.
Are you aware of the Try and Catch construct in VB? Do you know what it does?
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|

February 16th, 2006, 07:22 AM
|
|
Authorized User
|
|
Join Date: Sep 2004
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Imar,
On closer inspection I have concluded that the answer is 31.
Hope you agree and thanks for all your input.
Regards
Brett
|
|
 |