invalid arguments

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I kind of got thrown into C# without any real programming experience, so I
know this is probably an easy question, but it's driving me crazy. In my
Tabs class, as I'm leaving a tabpage, I'm trying to capture the screen as a
bitmap. I'm trying to tell it to call the CaptureTab method from a class
called Print.
private void tabLeave(object sender, System.EventArgs e)
{
...
Print.CaptureTab(System.Windows.Forms.Form frm);
}
but I get an error inside the parentheses - it's unhappy with frm and says )
expected. Then I erase the frm to get the 'System.Windows.Forms.Form'
denotes a 'class' where a 'variable' was expected error. Then I try just
(frm) and get The name 'frm' does not exist in the class or namespace
'HCAUT.Tabs'. Then when I use (this) I get An object reference is required
for the nonstatic field, method, or property
HCAUT.Print.CaptureTab(System.Windows.Forms.Form)'. I try (e) and get The
best overloaded method match for
'HCAUT.Print.CaptureTab(System.Windows.Forms.Form)' has some invalid
arguments. And finally I just leave it empty and get No overload for
method 'CaptureTab' takes '0' arguments.
(My CaptureTab method looks like this:
CaptureTab(System.Windows.Forms.Form frm))

Anybody know what I can do to get this to work?

Thanks for any help!!!!
Melanie
 
hi,

is this a compiler or runtime error?

from the little piece of code you posted it seems you have an extra closing
parentesis:
CaptureTab(System.Windows.Forms.Form frm))

but I canont be sure unless you post the entire code.


cheers,
 
melanieab said:
Hi,
I kind of got thrown into C# without any real programming experience,
so I know this is probably an easy question, but it's driving me
crazy. In my Tabs class, as I'm leaving a tabpage, I'm trying to
capture the screen as a bitmap. I'm trying to tell it to call the
CaptureTab method from a class called Print.
private void tabLeave(object sender, System.EventArgs e)
{
...
Print.CaptureTab(System.Windows.Forms.Form frm);
}
but I get an error inside the parentheses - it's unhappy with frm and
says ) expected. Then I erase the frm to get the
'System.Windows.Forms.Form' denotes a 'class' where a 'variable' was
expected error. Then I try just (frm) and get The name 'frm' does
not exist in the class or namespace 'HCAUT.Tabs'. Then when I use
(this) I get An object reference is required for the nonstatic
field, method, or property
HCAUT.Print.CaptureTab(System.Windows.Forms.Form)'. I try (e) and
get The best overloaded method match for
'HCAUT.Print.CaptureTab(System.Windows.Forms.Form)' has some invalid
arguments. And finally I just leave it empty and get No overload
for method 'CaptureTab' takes '0' arguments. (My CaptureTab method
looks like this:
CaptureTab(System.Windows.Forms.Form frm))

Anybody know what I can do to get this to work?

Thanks for any help!!!!
Melanie

To start at the end:
The method definition "CaptureTab(System.Windows.Forms.Form frm)"
means: this is a method with name "CaptureTab". It accepts a single parameter
of type "System.Windows.Forms.Form", which internally is called "frm".
By the way: you didn't specify a returntype, which is required (although
it can be "void", meaning "nothing returned").

When you call this method, you will have to supply a variable
of the correct type (System.Windows.Forms.Form), or one which is
derived from that type (some specific form definition in this case).
If you supply a variable, the only requirement is that the *type* matches,
the *name* is irrelevant.

When you write
Print.CaptureTab(System.Windows.Forms.Form frm);
you are *declaring* a new variable (frm), but this is illegal at this point.
When you declare a variable, you only define a space where later
some real data is placed.

So you need to find some way to get a reference to the particular form
that you want to "CaptureTab". Sort of:
System.Windows.Forms.Form myFrm;
myFrm = ??????
Print.CaptureTab(myFrm);

If you have the tabLeave method inside a form, then you could use "this"
to supply the current form to your CaptureTab method.
either use
myFrm = this;
in the lines above, or just replace all three with
Print.CaptureTab(this);

But this is pretty basic stuff, maybe you should find some "introduction
to programming" book to get some basis.

Hans Kesting
 
Back
Top