944,137 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 9421
  • VB.NET RSS
Mar 18th, 2005
0

passing values

Expand Post »
I am having difficulty understanding the process of passing values in vb..
If you name a sub procedure (Subsum) in one event procedure can you call it in another using the sam ecaal statement? and do you have to use the same
parameter(byval-byref)? I am quite new to programming
Thanks
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
guins100 is offline Offline
3 posts
since Mar 2005
Mar 19th, 2005
0

Re: passing values

Umm ecaal statement???


OK, see if this helps.

Dim nValue1 as Integer
Dim nValue2 as Integer
Dim nResult as Integer

nValue1 = 5
nValue2 = 10
nResult = AddValues(nValue1, nValue2)

Function AddValues(Paramater1 as Integer, Parameter2 as Integer) as Integer
AddValues = Parameter1 + Parameter2
Return AddValues
End Function

Msgbox "The Result is: " nResult

The values are passed to the procedure by Calling the AddValues Function, which accepts to arguements (or parameters).

1. ByVal is used when you don't want the procedure (function) to modify the variable that is passed to the procedure through an arguement.

2. ByRef is ued when you want to allow the procedure to modify the variable that is passed to the procedure.



Hope this helps
Team Colleague
Reputation Points: 211
Solved Threads: 27
Master Poster
Paladine is offline Offline
793 posts
since Feb 2003
Mar 20th, 2005
0

Re: passing values

Sorry about the mis-spelling.Yes it does help, I am curious though, can I have an event procedure(btnDisplay_click) call Function AddValues, and then have another event procedure(btnTotal_click) call the Function AddValues?Or do I need to make it a Sub procedure? Thank You for your help. I do seem to be having a brain-fart with this one
Reputation Points: 10
Solved Threads: 0
Newbie Poster
guins100 is offline Offline
3 posts
since Mar 2005
Mar 20th, 2005
0

Re: passing values

Yes, You can have multiple sub-routines call a function.
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Mar 21st, 2005
0

Re: passing values

Thanks to those that answered my questions.
It has helped tremendously.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
guins100 is offline Offline
3 posts
since Mar 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: link text boxes with listbox
Next Thread in VB.NET Forum Timeline: Counting text in a field





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC