.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old June 12th, 2004, 01:36 PM
DeBruyne DeBruyne is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 1 DeBruyne User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Smile Code Output ..!:

Hi everybody !


Who may solve this problem out :

What is the value of c, after execution of the followong Code sample??:


***********

Dim c As Integer
c = 1
CheckValue(c)
...
Sub CheckValue(ByVal iValue As Integer)
...
iValue = 13
End Sub

************

Thank you .. !


DEBRUYNE
URL

Reply With Quote
  #2  
Old June 12th, 2004, 03:34 PM
tibby tibby is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 6 tibby User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
c still equals 1. If you want to change c to be 17 in the function, pass it ByRef, or make the CheckValue a function with a return type. Based off your post, you want to do this:

Sub CheckValue(ByRef iValue as Integer)

Passing ByRef passes the object, passing ByVal passes the Value of the object.

HTH,
Tibby

Reply With Quote
  #3  
Old June 14th, 2004, 12:41 AM
topi topi is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 6 topi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
support...

Quote:
Originally Posted by DeBruyne
Hi everybody !


Who may solve this problem out :

What is the value of c, after execution of the followong Code sample??:


***********

Dim c As Integer
c = 1
CheckValue(c)
...
Sub CheckValue(ByVal iValue As Integer)
...
iValue = 13
End Sub

************

Thank you .. !


DEBRUYNE
http://forums.devarticles.com/images/icons/icon7.gif

yeah tibby is right...even c assign a value of 1. When you pass to the Sub CheckValue(ByVal iValue As Integer)... the iValue now is 1 which you pass, but in the method, you assign iValue which is equal to 13, you have a new value stored in iValue, so after the execution, still c is equal to 1 and your iValue is 13...
unless you make a function which return a value that makes c change...

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgramming.NET Development > Code Output ..!:


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT