Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 2nd, 2005, 12:22 PM   #1
Vengeance
Newbie
 
Join Date: Apr 2005
Posts: 8
Rep Power: 0 Vengeance is on a distinguished road
Using variables from other classes/frames

What's the exact way to just use a variable from another frame/class. I have 4 frames and I want my program to set the text on some labels in form 2 which will be done in form 1.

How exactly would I go about doing this?

I keep getting this error when I try, "non-static variable fNamelbl cannot be referenced from a static context". Can someone tell me what I'm doing wrong?

Last edited by Vengeance; May 2nd, 2005 at 2:44 PM.
Vengeance is offline   Reply With Quote
Old May 3rd, 2005, 6:20 AM   #2
Easter Bunny
Programmer
 
Easter Bunny's Avatar
 
Join Date: Mar 2005
Location: different places. constantly on the run.
Posts: 57
Rep Power: 4 Easter Bunny is on a distinguished road
that's when you try to use a normal variable like

int i;

instead of

static int i;

in a method that has been declared static(usually happens in the main method for me). i'm not entirely sure of it, but i think you can get to the variables with

Chair chair = new Chair();
chair.legs = 4;

else, what you can do, is use a method.

chair.setLegs( 4 );

then, in that method you assign the value 4 to the legs variable in that class and the do whatever you want to do with the object.

am i on the button?
__________________
There's got to be more to life than being really, really
ridiculously good looking
Easter Bunny is offline   Reply With Quote
Old May 4th, 2005, 8:59 AM   #3
Vengeance
Newbie
 
Join Date: Apr 2005
Posts: 8
Rep Power: 0 Vengeance is on a distinguished road
Yep, thanks.
Vengeance is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 6:37 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC