|
-
Nov 16th, 2007, 02:07 AM
#1
Thread Starter
Hyperactive Member
[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
Where there is no hope, there can be no endeavor.
There are two ways of rising in the world, either by your own industry or by the folly of others.
-
Nov 16th, 2007, 04:31 AM
#2
Re: Seek for help of Some theory question
1. Yes
2. Any of those will work just fine.
3. Depends on the situation
-
Nov 16th, 2007, 04:33 AM
#3
Thread Starter
Hyperactive Member
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 ?
Where there is no hope, there can be no endeavor.
There are two ways of rising in the world, either by your own industry or by the folly of others.
-
Nov 16th, 2007, 07:47 AM
#4
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
-
Nov 16th, 2007, 08:00 PM
#5
Thread Starter
Hyperactive Member
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.
Where there is no hope, there can be no endeavor.
There are two ways of rising in the world, either by your own industry or by the folly of others.
-
Nov 16th, 2007, 08:09 PM
#6
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
-
Nov 16th, 2007, 08:14 PM
#7
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
-
Nov 16th, 2007, 09:42 PM
#8
Thread Starter
Hyperactive Member
Re: Seek for help of Some theory question
Very clear explaination from tg ,Hack and Martinliss. You all are helpful.
Last edited by nUflAvOrS; Nov 16th, 2007 at 09:46 PM.
Where there is no hope, there can be no endeavor.
There are two ways of rising in the world, either by your own industry or by the folly of others.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|