Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > BOOK: Beginning ASP.NET 4 : in C# and VB
Password Reminder
Register
| FAQ | Members List | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 2nd, 2012, 11:52 AM
Registered User
Points: 17, Level: 1
Points: 17, Level: 1 Points: 17, Level: 1 Points: 17, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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?
Reply With Quote
  #2 (permalink)  
Old June 2nd, 2012, 12:37 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 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!
Reply With Quote
  #3 (permalink)  
Old June 2nd, 2012, 01:49 PM
Registered User
Points: 17, Level: 1
Points: 17, Level: 1 Points: 17, Level: 1 Points: 17, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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..
Reply With Quote
  #4 (permalink)  
Old June 2nd, 2012, 02:53 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 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!
Reply With Quote
Reply


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
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



All times are GMT -4. The time now is 01:53 AM.


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