Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > VBA / Office Integration > Word, PowerPoint, Outlook, and Other Office Products > vba ByRef and ByVal Variable Declaration


Reply
 
Thread Tools Display Modes
  #1  
Old 12-22-2006, 02:33 AM
mukudu99 mukudu99 is offline
Newcomer
 
Join Date: Dec 2006
Posts: 2
Unhappy vba ByRef and ByVal Variable Declaration


Hi VBA Gurus
couls anyone kindly explain to me what this code does if suppliied with the following values:1,2,3,4,5

'example on passing arguments byref declaration
Function test2(a As Integer)
a = a - 2

If a = 0 Or a < 0 Then
test2 = 2
Exit Function
End If
test2 = test2(a) * (a + 10)
End Function
Sub calc2()
Dim aa As Integer
aa = InputBox("enter integer ", "integer", 0)
MsgBox aa
MsgBox test2(aa)
MsgBox aa
End Sub

i can not seem to figure out how the outcomes are being calculated

thanks
Reply With Quote
  #2  
Old 12-22-2006, 04:49 AM
herilane's Avatar
herilane herilane is offline
Unashamed geek

Retired Moderator
* Expert *
 
Join Date: Jul 2003
Location: London, England
Posts: 8,988
Default

Sorry, this sounds like a homework assignment to me...

Why don't you:
  • Try running (or even better, stepping through) the code and seeing what happens to the variables, using the Locals window
  • Read about Byval and Byref in the help files
Reply With Quote
  #3  
Old 12-22-2006, 06:42 AM
mukudu99 mukudu99 is offline
Newcomer
 
Join Date: Dec 2006
Posts: 2
Default

thanks friend
i am actually teaching myself Access VBA.
I last had an assignment ten years ago.
been out of programming from the cobol and pascal days.
Just stepped thru the code as suggested and i am now able to see what is happening.

thanks
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->