Results 1 to 8 of 8

Thread: [RESOLVED] Seek for help of Some theory question

  1. #1

    Thread Starter
    Hyperactive Member nUflAvOrS's Avatar
    Join Date
    Jul 2007
    Location
    Malaysia/ Currently at Singapore
    Posts
    372

    Resolved [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 ...


    1. isn't 4 of answer i listed down is correct solution ?
    2. Got any others method can fulfill my request ?
    3. 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.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Seek for help of Some theory question

    1. Yes
    2. Any of those will work just fine.
    3. Depends on the situation

  3. #3

    Thread Starter
    Hyperactive Member nUflAvOrS's Avatar
    Join Date
    Jul 2007
    Location
    Malaysia/ Currently at Singapore
    Posts
    372

    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.

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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

  5. #5

    Thread Starter
    Hyperactive Member nUflAvOrS's Avatar
    Join Date
    Jul 2007
    Location
    Malaysia/ Currently at Singapore
    Posts
    372

    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.

  6. #6
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    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

  7. #7
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  8. #8

    Thread Starter
    Hyperactive Member nUflAvOrS's Avatar
    Join Date
    Jul 2007
    Location
    Malaysia/ Currently at Singapore
    Posts
    372

    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
  •  



Click Here to Expand Forum to Full Width