![]() |
| | #1 |
| Registered User Join Date: Aug 2004
Posts: 731
| how do I perform an action over and over... Code: namespace Drug_Wars
{
partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
int health = 100;
}
textBox_health.Text = health;
}
}
|
| Rune Hunter is offline | |
| | #2 |
| the hat of redundancy hat Join Date: Aug 2001 Location: Hannover, Germany
Posts: 2,769
| First, your "health" has to be a class scope variable. Right now, it's scope is the constructor. Outside the constructor, no "health" exists. If you want an event to occur whenever "health" is changed ( for example putting the new value in the textbox ) a property would be fine. The set method could set the textbox ( for simplicity ) or call an OnHealthChanged Event. But I guess that's a bit much, so as step one, declare "health" in the scope of your form like this Code: namespace Drug_Wars
{
partial class Form1 : Form
{
private int health = 100;
public Form1()
{
InitializeComponent();
textBox_health.Text = health.ToString();
}
}
}
__________________ hth -nv She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate." When in doubt, read the FAQ. Then ask a smart question. |
| nvoigt is offline | |
| | #3 |
| Registered User Join Date: Aug 2004
Posts: 731
| ok I fixed the varible. But the onHealthChanged event didn't work. Code: private void onHealthChanged()
{
textBox2.Text = health.ToString();
}
|
| Rune Hunter is offline | |
| | #4 |
| the hat of redundancy hat Join Date: Aug 2001 Location: Hannover, Germany
Posts: 2,769
| Well, you will have to implement the event yourself. Start by creating a property for Health.
__________________ hth -nv She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate." When in doubt, read the FAQ. Then ask a smart question. |
| nvoigt is offline | |
| | #5 |
| Registered User Join Date: Aug 2004
Posts: 731
| ok well umm.... creating a property huh? like I said I am new so umm.... how do you do that? |
| Rune Hunter is offline | |
| | #6 |
| Registered User Join Date: Aug 2004
Posts: 731
| while I am on this topic, I don't want to start a new topic, I have anouther question. Why can't any of my friends (running windows xp and some sp and other sp2) nto able to run my programs I made with visual c#. They get an error somtimes saying missing a dll or a memory error or somthing but there computer works fine. Is it because I have .net framework 2.0 beta 1 and not 1.0 installed? |
| Rune Hunter is offline | |
| | #7 | |
| Registered User Join Date: Mar 2002
Posts: 4
| Quote:
Version 1 and 2 .NET Framework should happily co-exist on the same machine. Mine does | |
| Jarad is offline | |
| | #8 |
| Registered User Join Date: Aug 2004
Posts: 731
| dang it! This is sooooooo not cool. Well it appears some stuff don't even work with visual c# 2005 beta. So what do you recomend that uses 1.0 framework. I mean is there anouther free version of vusual C# that uses framework 1.0? |
| Rune Hunter is offline | |
| | #9 |
| Banned Join Date: Feb 2003 Location: Australia
Posts: 986
| www.icsharpcode.net/OpenSource/SD/ uses the .NET Framework 1.1 runtime (the most common version). It's open source, you might give it a try. |
| nickname_changed is offline | |
| | #10 |
| Banned Join Date: Feb 2003 Location: Australia
Posts: 986
| And there are no free versions of Visual C#, the one you have is only free at the moment because it's beta. My recommendation would be to get a book about C# that will teach you why what you have done isn't working. Or you might like to read this: http://www.softsteel.co.uk/tutorials/cSharp/cIndex.html |
| nickname_changed is offline | |
| | #11 |
| Registered User Join Date: Aug 2004
Posts: 731
| maybe c# isn't for me then. Cause I hate sharp devolpe. I just can't stand it. I fallowed your link and tried it again but nope, I just don't like it. I am guessing you eithe cna't get visual c# 2003 or it costs money then. EDIT: And I do have a book on c#. Last edited by Rune Hunter; 02-24-2005 at 08:22 PM. |
| Rune Hunter is offline | |
| | #12 |
| Banned Join Date: Feb 2003 Location: Australia
Posts: 986
| A couple of thousand dollars I think. Do a search for Visual Studio 2003 60 Day Trial though, depending on where you live they may be able to post you a free trial pack. Don't hate C# because you don't like the IDE's, it is a very good language and if you take the time to learn it you will come to love it. And don't expect to understand it all in a few days either - I work with people who have been using it for the past two years and are still learning new things. Programmers wouldn't get paid so much if anyone could pick up Visual Studio and write MS Word in 2 days. |
| nickname_changed is offline | |
| | #13 |
| Registered User Join Date: Aug 2004
Posts: 731
| lol it ins't because I don't know c#. And I do love the lang. Just that sharp devlope gives me an error I didn't create, and I just don't like it. Maybe if the product worked right I would like it, but right now I am not sure what to do. I found visual c# 2003 standard for abnout 80 dallors on amazon, but does 2003 use .net 1.1? or 1.0? |
| Rune Hunter is offline | |
| | #14 | |
| Super Moderator Join Date: Sep 2001
Posts: 4,746
| Quote:
| |
| sean is offline | |
| | #15 | |
| the hat of redundancy hat Join Date: Aug 2001 Location: Hannover, Germany
Posts: 2,769
| Quote:
__________________ hth -nv She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate." When in doubt, read the FAQ. Then ask a smart question. | |
| nvoigt is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|