Wrox Programmer Forums
|
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
 
Old June 2nd, 2012, 11:52 AM
Registered User
 
Join Date: Jun 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Functions and Subroutines

I'm reading chapter 5, till now everything is fine but I reached Functions and Subroutines and got really confused anyone please tell me what are they exactly and how they work?
 
Old June 2nd, 2012, 12:37 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

As explained in the book, functions are reusable blocks of code that return something; subs are reusable blocks of code that don't return a value.

What is it you don't understand exactly?

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
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!
 
Old June 2nd, 2012, 01:49 PM
Registered User
 
Join Date: Jun 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The example in the book on page 171, for the parameters you wrote "ByVal a As Integer" but the code in the calculator has Value1 variable so how are they related?

I skipped functions and classes and started with chapter 6 but found it to be hard to follow up without a solid understanding of the previous sections.

I'm sorry if my question isn't proper or professional :p but i'm still an amateur.

Is there any link where I can get a deeper understanding.

By the way I really liked this book and recommended it on amazon just in case my post implies the opposite.

Last edited by zaid; June 2nd, 2012 at 01:52 PM..
 
Old June 2nd, 2012, 02:53 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

The a parameter is part of the definition of the function / sub (collectively referred to as methods). When you need to pass a value (called an argument) to that method, you can pass a literal value or the value of a variable (Value1, in your example).

So, a function like this:

Public Function Add (ByVal a As Integer, ByVal B As Integer) As Integer
Return a + b
End Function

can be called like this:

Dim result As Integer = myCalculator.Add(2, 4)

or like this:

Dim value1 As Integer = 2
Dim value2 As Integer = 4
Dim result As Integer = myCalculator.Add(value1, value2)

There's no relation in name between the parameters of the method, and the values you pass to it.

Maybe this helps: http://msdn.microsoft.com/en-us/libr...(v=vs.80).aspx

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
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!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Functions rwhammond BOOK: JavaScript 24-Hour Trainer 2 June 21st, 2011 01:22 PM
Using functions crashbandicoot BOOK: Beginning HTML, XHTML, CSS, and JavaScript 0 April 12th, 2011 06:21 PM
C# functions daniel.mihalcea C# 2008 aka C# 3.0 3 September 11th, 2008 05:10 PM
Creating a library of subroutines kscase Pro Visual Basic 2005 5 July 6th, 2007 02:58 PM
Functions czambran BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0 13 July 11th, 2006 06:33 PM





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