passing values

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Mar 2005
Posts: 3
Reputation: guins100 is an unknown quantity at this point 
Solved Threads: 0
guins100 guins100 is offline Offline
Newbie Poster

passing values

 
0
  #1
Mar 18th, 2005
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
Reply With Quote Quick reply to this message  
Join Date: Feb 2003
Posts: 793
Reputation: Paladine has a spectacular aura about Paladine has a spectacular aura about Paladine has a spectacular aura about 
Solved Threads: 26
Team Colleague
Paladine's Avatar
Paladine Paladine is offline Offline
Master Poster

Re: passing values

 
0
  #2
Mar 19th, 2005
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
Assistant Manager, Pharmacy Informatics
Wordpress Learning Blog
Updated : ASP.Net Login Code
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 3
Reputation: guins100 is an unknown quantity at this point 
Solved Threads: 0
guins100 guins100 is offline Offline
Newbie Poster

Re: passing values

 
0
  #3
Mar 20th, 2005
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
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: passing values

 
0
  #4
Mar 20th, 2005
Yes, You can have multiple sub-routines call a function.
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 3
Reputation: guins100 is an unknown quantity at this point 
Solved Threads: 0
guins100 guins100 is offline Offline
Newbie Poster

Re: passing values

 
0
  #5
Mar 21st, 2005
Thanks to those that answered my questions.
It has helped tremendously.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC