[RESOLVED] Seek for help of Some theory question
When we want to pass a value from one form to another form.
1. We may pass to a label of another form
2. Declare a global variable and assign a value to variable.
3. Pass a value to global property.
4. Pass through a global function
Hereon, i need to know ...
- isn't 4 of answer i listed down is correct solution ?
- Got any others method can fulfill my request ?
- In what condition is suitable to use property ?
Thanks in advance :thumb:
Re: Seek for help of Some theory question
1. Yes
2. Any of those will work just fine.
3. Depends on the situation
Re: Seek for help of Some theory question
I confused against global variable and global property.
What different between this two. Why we want to use property instead of public variable ?
Re: Seek for help of Some theory question
This is an example of a global property
Code:
Public Property Get Test() As String
Test = sValue
End Property
Public Property Let Test(ByVal vNewValue As String)
sValue = vNewValue
End Property
This is an example of a global variable
Code:
Public Test As String
Re: Seek for help of Some theory question
Thanks Hack,
I know the coding method. Just wondered in what of the condition i have to use property and in what of the condition i need to use public.
Re: Seek for help of Some theory question
A Public variable is just a variable. A Public Property can be used as a variable but it can also contain code. For example
Code:
Public Property Let Test(ByVal vNewValue As String)
If Len(vNewValue) < 10 Then
Test = vNewValue
Else
Msgbox "Too long"
End If
End Property
Re: Seek for help of Some theory question
the property is also a part of the object in which it's created. In this case, a form. And multiple instances of the same form can have different values. A global variable can only have one value.
-tg
Re: Seek for help of Some theory question
Very clear explaination from tg ,Hack and Martinliss. You all are helpful.