المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : مساعدة



msa5
23-10-2004, 08:57 PM
اذا ممكن حد يشرحلي ال function , procedures انا فاهم الفكرة العامة بس مش فاهم امتا بنستعمل function وامتا بنستعمل procedures و byref , byval

2501
24-10-2004, 09:08 PM
u use function when u need it... :D

byval means the parameter value passed into the function or procedure can not be changed when the application returns from the function or procedure...

byref or ref or & or % means that the value of the original variable that was passed as a parameter to this function or proc. can be changed when the application returns from the function or proc.

C/CPP/CPP.NET:
it is good practice to pass huge variables to a function as a constant reference...(effecient)

msa5
25-10-2004, 04:18 PM
u use function when u need it...:D i know but i mean what the differance between the function and the procedures

amgadpasha
25-10-2004, 05:02 PM
what s th language u r using, not all th language supports procedures, mainly proc r functions that doesn't return values, so u call them for doing something, like printing something on the screen or whatever static senarios, sometimes procedurs also doesn't take parameters or arguments, so it's just a fixed behaviour, but again, this is based on the language u r using, in c for example there is nothing called procedurs

moh_mhe
25-10-2004, 11:39 PM
Procedure

يمكنك عمله لإجراءات معينة مع إرسال Parameters و لكن بدون إرجاع قيمة



Fuction

نفس عمل Procedure ولكن يمكنك إرجاع قيمة



Example to calculate the sum of to numbers by VB



Procedure:

Sub GetSum(Val1 As long,Val2 As Long,ByRef Val_Sum As long)

Val_Sum =Val1 +Val2

End Sub



Function:

Function F_GetSum(Val1 as long,Val2 as Long) As Long

F_GetSum =Val1 +Val2

End Sub



''How to get the sum of 4 and 5

Procedure:

Dim V_SUM As long

Call GetSum 4,5, V_SUM



'Function:

V_SUM =f_GetSum(4,5)

msa5
28-10-2004, 02:44 PM
thanks for everyone

i use VB6 :D