Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB 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
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 20th, 2010, 11:56 AM
Registered User
Join Date: Nov 2010
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Default VB questions, around pg 185-ish

Hi Imar,
Got several VB beginners questions on some of the code regarding objects, propertys, etc. Probably best if I just ask them one at a time, so the first is this statement...
dim myCalculator As calculator = new calculator()
Isn't the 2nd Calculator redundant? You've already specified the class as Calculator with the 1st reference, and you've said this is a new instance -- so, what's the purpose of the 2nd reference?

Jeff S
Reply With Quote
  #2 (permalink)  
Old November 20th, 2010, 12:05 PM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts

VB (and other .NET languages) require this in order to specify the real type that is assigned to the variable. Since, because of object orientation, it's possible to assign a different type than the type of the variable, you need to be explicit. E.g. this would work as well:

Dim myCalculator As Object = New Calculator()

However, from that point on, myCalculator behaves as an Object unless you cast it back to a calculator.

As explained in the book, VB supports a short hand syntax:

Dim myCalculator As New Calculator()

This is functionally equivalent.

Hope this helps,

Imar Spaanjaars
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
The Following User Says Thank You to Imar For This Useful Post:
jefals (November 21st, 2010)

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Tab Bar Application starting at page 185 iPhoneNoob BOOK: Beginning iPhone SDK Programming with Objective-C 0 July 26th, 2010 12:05 PM
Chapter 9 pg 304 JavaScript questions skijor BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 3 August 5th, 2009 06:31 AM
5 Questions in VB ramk_1978 Beginning VB 6 1 January 14th, 2005 01:06 PM
VB Questions priyanka123 VB How-To 5 May 24th, 2004 07:53 AM

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