Geekzone: technology news, blogs, forums
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.

561 posts

Ultimate Geek


#41579 18-Sep-2009 21:23
Send private message

Help im real stuck! Im writing an assignment with 3 forms and want to access int rawScore and decimal averageScore from a seperate Form.

What do i type in the other form to call them?


public partial class NightClubForm : Form


int rawScore;
decimal averageScore; 

public NightClubForm()



Create new topic
8035 posts

Uber Geek


  #256927 18-Sep-2009 21:45
Send private message

Ideally you want to use some kind of  software design pattern like MVC or MVP but presuming you don't have much time and they haven't taught you any good practice like that....  check out this the codeproject article below for an example of using events and delegates to solve this kind problem.

Note the author calls his article an example of the MVC pattern but it's actually an example of a simpler design pattern called the Observer pattern.

561 posts

Ultimate Geek


  #257040 19-Sep-2009 15:36
Send private message

im a novice at this, all i want to do is to use int rawScore which is given a value in form1 and then use it in form 2



835 posts

Ultimate Geek


  #257071 19-Sep-2009 18:17
Send private message

s.joseph: im a novice at this, all i want to do is to use int rawScore which is given a value in form1 and then use it in form 2

Aye, I can well believe you're an absolute novice if you're asking this sort of question Laughing. While Visual Studio is a great tool which allows for rapid prototyping it is also a major pitfall - a lot of students these days are thought quick'n'dirty drag'n'drop "programming" and earn their "Object Oriented Programming" certificates that way. Your question absolutely begs even more questions, i.e. have you heard of the basic tennets of OO, and things you are able to do, such as encapsulation, etc?

The quickest and dirtiest way to answer your question is to declare those members public by simply adding that keyword in front of the property type, eg. "public int someIntOrOther;". You can then access this property from any instance of that form. This is assuming you know about the definition of an "object" being an "instance" of a "class"? Sorry, I have no idea how much of a novice you are. My suggestion is don't go straight to Windows Forms programming - play around with console apps and improve your OO skills first. Build a solid foundation and Windows Forms stuff will come easily - your questions such at this will be answered during your play with simple console apps.

This is just my view of course - this was how I learned, way back in the old C++ and Java days, getting my head around things after Pascal. You may have different learning preferences. Learn basic OO first, then figure out best practices, followed by patterns - or all together in the same time. If you're asking this sort of questions then reading about MVC, and trying to implement it, may not be the most fruitful learning exercise. Having said that, I have not read the article Ragnor mentioned - it may well be a well formed article guiding you from the basics of OO to patterns and best practices, in which case HOOORAH!

Android user, software developer, a semi-typical (not a gamer) geek, and a Bernese Mountain Dog nut! |

424 posts

Ultimate Geek

  #257076 19-Sep-2009 19:06
Send private message

You can always ask on

12 posts


  #257081 19-Sep-2009 19:36
Send private message

s.joseph: Help im real stuck! Im writing an assignment with 3 forms and want to access int rawScore and decimal averageScore from a seperate Form.

Hey, this assignment looks familiar to me!

If you are doing INFO 102 at VUW, then you do not need 3 forms. Use a message box to display rawScore and averageScore. Read the assignment carefully, look at the hints and ask question on the discussion board.

561 posts

Ultimate Geek


  #257183 20-Sep-2009 12:43
Send private message

haha, oh. that makes sense.
Thanks man

27 posts


  #258768 27-Sep-2009 20:17
Send private message

Hi there,

I always prefer simplicity, if at all possible no sense in over engineering if not necessary.
I would do something like this:

public partial class NightClubForm : Form {
int rawScore;
decimal averageScore;

public NightClubForm() {

public int RawScore { get { return rawScore; } }
public decimal AverageScore { get { return averageScore; } }

// Your other form code

These can now be accessed by other areas of your code as follows:

var theAverageScore = form1.AverageScore;
var theRawScore = form1.RawScore;

Hope that helps mate

Create new topic

Twitter and LinkedIn »

Follow us to receive Twitter updates when new discussions are posted in our forums:

Follow us to receive Twitter updates when news items and blogs are posted in our frontpage:

Follow us to receive Twitter updates when tech item prices are listed in our price comparison site:

News »

OPPO Find X2 Lite brings flagship features to mid-range 5G smartphone
Posted 29-May-2020 12:52

Sony introduces the digital camera ZV-1 for content creators
Posted 27-May-2020 12:47

Samsung Announces 2020 QLED TV Range
Posted 20-May-2020 16:29

D-Link A/NZ launches AI-Powered body temperature measuring system
Posted 20-May-2020 16:22

NortonLifeLock Online Banking Protection now available for New Zealand banks
Posted 20-May-2020 16:14

SD Express delivers new gigabyte speeds for SD memory cards
Posted 20-May-2020 15:00

D-Link A/NZ launches Nuclias cloud managed network solution hosted in Australia
Posted 11-May-2020 17:53

Logitech introduces new video streaming solution for home studios
Posted 11-May-2020 17:48

Next generation Volvo cars to be powered by Luminar LiDAR technology
Posted 7-May-2020 13:56

D-Link A/NZ launches Wi-Fi Certified EasyMesh system
Posted 7-May-2020 13:51

Spark teams up with Microsoft to bring Xbox All Access to New Zealand
Posted 7-May-2020 13:01

Microsoft plans to establish its first datacenter region in New Zealand
Posted 6-May-2020 11:35

Genesis School-gen has joined forces with Mind Lab Kids
Posted 1-May-2020 12:53

Malwarebytes expands into privacy with fast, frictionless VPN
Posted 30-Apr-2020 16:06

Kordia to donate TV airtime on Channel 200 to community groups
Posted 30-Apr-2020 16:00

Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.

Support Geekzone »

Our community of supporters help make Geekzone possible. Click the button below to join them.

Support Geezone on PressPatron

Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.

Alternatively, you can receive a daily email with Geekzone updates.