Wrox Programmer Forums
|
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
 
Old February 15th, 2006, 09:18 AM
Authorized User
 
Join Date: Sep 2004
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Brettvan1
Default 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.


 
Old February 15th, 2006, 10:18 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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.
 
Old February 15th, 2006, 11:18 AM
Authorized User
 
Join Date: Sep 2004
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Brettvan1
Default

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

 
Old February 15th, 2006, 11:45 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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.
 
Old February 15th, 2006, 12:01 PM
Authorized User
 
Join Date: Sep 2004
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Brettvan1
Default

Just can't seem to get it.....

Well, thanks for your help anyway Imar.

Regards
Brett

 
Old February 15th, 2006, 12:30 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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.
 
Old February 15th, 2006, 12:53 PM
Authorized User
 
Join Date: Sep 2004
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Brettvan1
Default

Aaah, ok...so the answer is e ?

Excellent thanks so much.

Kind regards
Brett

 
Old February 15th, 2006, 12:59 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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.
 
Old February 16th, 2006, 07:22 AM
Authorized User
 
Join Date: Sep 2004
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Brettvan1
Default

Hi Imar,

On closer inspection I have concluded that the answer is 31.

Hope you agree and thanks for all your input.

Regards
Brett






Similar Threads
Thread Thread Starter Forum Replies Last Post
Encryption Testing dkb Javascript 1 January 5th, 2007 06:37 AM
Testing for ChannelMode interrupt Javascript How-To 0 June 30th, 2006 08:21 AM
need self testing questions netcat Perl 1 April 22nd, 2006 06:21 AM
Unit Testing userrob BOOK: ASP.NET Website Programming Problem-Design-Solution 2 November 9th, 2005 10:35 AM
testing mark C# 0 June 4th, 2003 08:37 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.