newbie help

  • Thread starter Thread starter Dave
  • Start date Start date
D

Dave

just a few beginner questions...you don't have to answer everyone...I wrote
a windows application but I don't know how to write text to the screen. I
just need to be able to write a number to the screen and replace it as that
number changes in my program. I tried writing a textbox and saying
textbox.text = mystring; but that wouldn't work because there was a problem
with declaring mystring.
Also how do you inheret from two classes? I don't know the syntax
for writing class form1 : firstclass, secondclass. I wanted to make my form
inheret from a static class that I use for my global static variables. I
couldn't figure out how to make global variables so I just created a static
class and made everyclass inheret it. that way I can access that same
variables, or thousands of variables without passing them all by reference
to the functions. any better ideas for doing this?
also how do I stop visual studio from telling me that it can't build
my progrma because it can't copy "filename" to the run directory? I build
very often because I'm new to the language and I make mistakes everytime I
write a piece of code and after doing it a couple times or so in a row it
gives me three errors like that.
thanks in advance
dave
 
Comments below...

Dave said:
I tried writing a textbox and saying
textbox.text = mystring; but that wouldn't work because there was a problem
with declaring mystring.

I can't answer that one without more information. You've probably declared
mystring in one scope and are trying to use it from another scope. Or else
your declaration of mystring is using the wrong syntax.
Also how do you inheret from two classes?

This is called "multiple inheritance" and it's not supported in .NET
languages. You can inherit one class and any number of interfaces. But for
the purpose you describe below you don't really need multiple inheritance.
I wanted to make my form
inheret from a static class that I use for my global static variables. I
couldn't figure out how to make global variables so I just created a static
class and made everyclass inheret it.

You don't need to inherit that class in order to access its static members.
As long as the class is public and the static or const fields are public,
you can access them from your class. Example:

public class Globals
{
public const string Foo = "Hello";
}

public class MyClass
{
string s;

public MyClass()
{
s = Globals.Foo;
}
}

If the global variables are actually variables and not constants, I wouldn't
recommend using a global class. Take another look at your app and come up
with a way to organize your data so that you don't need global variables.
Global constants are OK, though. For example, Math.PI, String.Empty,
TimeSpan.Zero, etc.
also how do I stop visual studio from telling me that it can't build
my progrma because it can't copy "filename" to the run directory?

This happens if the .dll or .exe is still in use. For example if you build
an .exe, run it from outside the IDE, and then try to rebuild it while it's
still running, you could get this type of error.
 
Bret Mulvey said:
Comments below...



I can't answer that one without more information. You've probably declared
mystring in one scope and are trying to use it from another scope. Or else
your declaration of mystring is using the wrong syntax.


This is called "multiple inheritance" and it's not supported in .NET
languages. You can inherit one class and any number of interfaces. But for
the purpose you describe below you don't really need multiple inheritance.


You don't need to inherit that class in order to access its static members.
As long as the class is public and the static or const fields are public,
you can access them from your class. Example:

public class Globals
{
public const string Foo = "Hello";
}

public class MyClass
{
string s;

public MyClass()
{
s = Globals.Foo;
}
}

If the global variables are actually variables and not constants, I wouldn't
recommend using a global class. Take another look at your app and come up
with a way to organize your data so that you don't need global variables.
Global constants are OK, though. For example, Math.PI, String.Empty,
TimeSpan.Zero, etc.


This happens if the .dll or .exe is still in use. For example if you build
an .exe, run it from outside the IDE, and then try to rebuild it while it's
still running, you could get this type of error.
*******************************

ok, I figured out why my program is acting funny. the mystring declaration
gave me errors because I declared and used it incorrectly the first time and
then tried to compile it again after I had fixed it, but the computer was
giving me the same error from the first try that had an error. So I closed
that windowsapplication project and opened a new one, pasted the code in,
and tried it again. this time it compiled without a problem. obviouslly
something funny is going on. and it has everything to do with the fact that
my visual studio gives me the error: can't copy "filename" to the run
directory. but I never ran the program! all I did was press ctrl-shift-b,
which tells the compiler to build the program, every few seconds to see if I
fixed syntax errors and stuff. so what am I doing wrong? I'm not running the
program so its not in use. but this happens when I compile the program too
often. but its started to do it even if I only compile like three times,
even if they are several seconds apart it seems. maybe I have to save
changes before compiling?
But my last real problem anyway is trying to output to the screen from
the windowsapplication and then change that output as necessary during the
program run. how do I do this??? it doesn't matter if its a textbox that I
change the text of or even a button, but I just need to output to the screen
and change that output. what do I do?
thanks
dave
 
Bret Mulvey said:
Comments below...



I can't answer that one without more information. You've probably declared
mystring in one scope and are trying to use it from another scope. Or else
your declaration of mystring is using the wrong syntax.


This is called "multiple inheritance" and it's not supported in .NET
languages. You can inherit one class and any number of interfaces. But for
the purpose you describe below you don't really need multiple inheritance.


You don't need to inherit that class in order to access its static members.
As long as the class is public and the static or const fields are public,
you can access them from your class. Example:

public class Globals
{
public const string Foo = "Hello";
}

public class MyClass
{
string s;

public MyClass()
{
s = Globals.Foo;
}
}

If the global variables are actually variables and not constants, I wouldn't
recommend using a global class. Take another look at your app and come up
with a way to organize your data so that you don't need global variables.
Global constants are OK, though. For example, Math.PI, String.Empty,
TimeSpan.Zero, etc.


This happens if the .dll or .exe is still in use. For example if you build
an .exe, run it from outside the IDE, and then try to rebuild it while it's
still running, you could get this type of error.
*********
I made a mistake, I figured out why the compiler keeps telling me the
program is running. it seems to be because I ran the main program in main
and when you close the form, the main program continues to run, even though
you can't see it. so, I'm wondering, where do I put the main code for my
program? in the windows form? or in Main() ? the code doesn't wait for user
input so it just keeps going, if that means anything.
 
Back
Top