Results 1 to 14 of 14

Thread: VB.NET: Create and Apply Basic Classes

Hybrid View

  1. #1

    Thread Starter
    Addicted Member toytoy's Avatar
    Join Date
    Jul 2004
    Posts
    230
    ok...i guess i learnt something from that..

    thanks brown monkey for the explanation..

    I will continue to search for other useful links related to that in the forum...

    If you guys found any useful links.....remember to tell me


  2. #2

    Thread Starter
    Addicted Member toytoy's Avatar
    Join Date
    Jul 2004
    Posts
    230

    Re: VB.NET: Create and Apply Basic Classes

    Recently, i borrow a book from the author of Bradley/Millspaugh...

    I try the code on one of the chapters where it uses the class..

    I come across one HandOn program where i can't understand why the class of Payroll is not declared in the frmSummary form and it can still be use...

    but in the frmPayRoll form, it must declared a new instance of object first before it can be use...

    Can someone spare some time and look into this two forms...

    I can't figure out the reason...

    Thanks
    Attached Files Attached Files

  3. #3
    Fanatic Member brown monkey's Avatar
    Join Date
    Jun 2004
    Location
    Cebu
    Posts
    552

    Re: VB.NET: Create and Apply Basic Classes

    lblCount.Text = Payroll.NumberProcessed.ToString()
    lblOvertime.Text = Payroll.OvertimeHours.ToString()
    lblTotalPay.Text = FormatCurrency(Payroll.TotalPay)

    Are you talking about this one? It's because those properties are Shared. A member of the class, not the object itself. Notice the Console.WriteLine()? WriteLine() is a shared member method of Console class. You need no intantiation. Instantiation is for object and we are dealing about the class member.

  4. #4
    Frenzied Member Asgorath's Avatar
    Join Date
    Sep 2004
    Location
    Saturn
    Posts
    2,036

    Re: VB.NET: Create and Apply Basic Classes

    Hi
    The class can be used by frmSummary without creating an instance of the class because the following properties are all declared Shared.
    VB Code:
    1. Shared ReadOnly Property NumberProcessed() As Decimal
    2. Shared ReadOnly Property TotalPay() As Decimal
    3. Shared ReadOnly Property OvertimeHours() As Decimal
    Acording to MSDN The Shared keyword indicates that one or more declared programming elements are shared. Shared elements are not associated with a specific instance of a class or structure. You can access them by qualifying them either with the class or structure name, or with the variable name of a specific instance of the class or structure.

    Regards
    Jorge
    "The dark side clouds everything. Impossible to see the future is."

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