Results 1 to 3 of 3

Thread: Help

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2004
    Location
    Scotland
    Posts
    2

    Help

    I am trying to pass a variable in From a form to a class in Sun ONE studio
    Hello

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    A form is a class too.


    What do you mean by pass? If you're in the class' code and want to access a variable of the form you need a reference to the form and an accessor function for the member. If you're in the form's code and want to create an instance of the class and give it the variable, you need to pass it to the constructor. If you already have an instance of the class you could call a setter function for a property of class or pass it to individual methods you call.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    What kind of variable is it also? Reference or Primitive? As CornedBee pointed out in his suggestion, if you are in the form code you can simply create an instance of the class and pass the variable via the class constructor. I usualy use this method which is somtimes refered to as Aggregation. I often use Aggregation when i need a class to be able to invoke a method back on the class that was passed in as a reference. For primitive values that need to be passed in and modified i just define setter methods within my class while keeping the class members private as to keep everything properly encapsulated.

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