473,326 Members | 2,192 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Public Methods in Forms

jp
Hi.
I'm new to C#, but I've been programing in C++ and VB for years.
I wrote a public method inside a form:

public bool bConnect(string strServerName, string strDBName,
string strUser, string strPassword)
{
return (true);

}

The thing is that there is no way to call it from outside the form. I
can't even see it with the autocomplete feature:

private void aplicacionesToolStripMenuItem_Click(object
sender, EventArgs e)
{
Form frmApps = new clsFormApps();
frmApps.bConnect("", "", "", ""); -FAILS,
with error Error...

'System.Windows.Forms.Form' does not contain a definition for
'bConnect' and no extension method 'bConnect' accepting a first
argument of type 'System.Windows.Forms.Form' could be found (are you
missing a using directive or an assembly reference?) D:\tools
\ConfigPAL 2009\ConfigPAL\ConfigPAL\clsFormMain.cs 59 21 ConfigPAL

Thank you for your help.

Nov 7 '08 #1
7 1699
change:
Form frmApps = new clsFormApps();

to:
clsFormApps frmApps = new clsFormApps();
"jp" wrote:
Hi.
I'm new to C#, but I've been programing in C++ and VB for years.
I wrote a public method inside a form:

public bool bConnect(string strServerName, string strDBName,
string strUser, string strPassword)
{
return (true);

}

The thing is that there is no way to call it from outside the form. I
can't even see it with the autocomplete feature:

private void aplicacionesToolStripMenuItem_Click(object
sender, EventArgs e)
{
Form frmApps = new clsFormApps();
frmApps.bConnect("", "", "", ""); -FAILS,
with error Error...

'System.Windows.Forms.Form' does not contain a definition for
'bConnect' and no extension method 'bConnect' accepting a first
argument of type 'System.Windows.Forms.Form' could be found (are you
missing a using directive or an assembly reference?) D:\tools
\ConfigPAL 2009\ConfigPAL\ConfigPAL\clsFormMain.cs 59 21 ConfigPAL

Thank you for your help.

Nov 7 '08 #2
Form frmApps = new clsFormApps();
'System.Windows.Forms.Form' does not contain a definition for
'bConnect'
Declare it as

clsFormApps frmApps = new clsFormApps();

--
Pete
====
http://mrpmorris.blogspot.com
http://www.capableobjects.com
Nov 7 '08 #3
jp
On 7 nov, 10:22, "Peter Morris" <mrpmorri...@SPAMgmail.comwrote:
* * * * * *Form frmApps = new clsFormApps();
'System.Windows.Forms.Form' does not contain a definition for
'bConnect'

Declare it as

clsFormApps frmApps = new clsFormApps();

--
Pete
====http://mrpmorris.blogspot.comhttp://www.capableobjects.com
Yes, you were right. A silly mistake.
Thank you both.
Nov 7 '08 #4
"jp" <ju*********@gmail.comwrote in message
news:d3**********************************@w24g2000 prd.googlegroups.com...
I'm new to C#, but I've been programing in C++ and VB for years.
And it shows:
public bool bConnect(
I'm a VB guy, too, and I know how variants of Hungarian notation have been
beaten into our heads over the year, buy I IMPLORE you to try to give it up.
Please oh please drop the data type danglers from anything that's going to
be public.
Nov 7 '08 #5
On 07/11/2008 in message <e5**************@TK2MSFTNGP04.phx.gblJeff
Johnson wrote:
>I'm a VB guy, too, and I know how variants of Hungarian notation have been
beaten into our heads over the year, buy I IMPLORE you to try to give it
up. Please oh please drop the data type danglers from anything that's
going to be public.
I'd be interested to know why?
I am trying to give it up but about as successfully as giving up smoking :-(

--
Jeff Gaines Damerham Hampshire UK
If it's not broken, mess around with it until it is
Nov 7 '08 #6
"Jeff Gaines" <wh*********@newsgroups.nospamwrote in message
news:xn****************@msnews.microsoft.com...
>>I'm a VB guy, too, and I know how variants of Hungarian notation have been
beaten into our heads over the year, buy I IMPLORE you to try to give it
up. Please oh please drop the data type danglers from anything that's
going to be public.

I'd be interested to know why?
I am trying to give it up but about as successfully as giving up smoking
:-(
A) It's ugly.

B) It really is non-standard. Like it or not, I consider Microsoft to be an
authority when it comes to Windows programming, and I try to follow their
example. Let's go a little off-topic and look at some of the methods the VB6
Clipboard object exposes (in truth, the general concept applies equally to
..NET programming):

Function GetData([Format]) As IPictureDisp
Function GetFormat(Format As Integer) As Boolean
Function GetText([Format]) As String

Notice that they didn't name the functions objGetData, blnGetFormat, or
strGetText. In fact, no methods, properties, or events contain any of this
junk. Events, for example, aren't named ClickEvent, MoveEvent,
GotFocusEvent, but I've seen lots of people who think they need to beat it
into your head with a sledgehammer that you're dealing with an event.

If I were to use a third-party's library and every class started with "cls"
(oh GOD do I HATE this!!) and every non-void function was decorated with a
return type indicator I'd have second thoughts about ever dealing with that
third party again. Do you put a clsTextBox on a form? A clsLabel? No.
TextBox. Label. We know what they are!

Now, you may be writing something that's in-house only and will never be
used by anyone else, but on a personal level it doesn't matter to me. I
consider following MS's standards to be the professional way to do things,
and I strive to be a professional even if no one's ever going to see my
stuff but me.

It is, of course, just my opinion.
Nov 7 '08 #7
On 07/11/2008 in message <eZ**************@TK2MSFTNGP03.phx.gblJeff
Johnson wrote:
>It is, of course, just my opinion.
Interesting though, thank you :-)

--
Jeff Gaines Damerham Hampshire UK
All those who believe in psychokinesis raise my hand.
Nov 7 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

99
by: David MacQuigg | last post by:
I'm not getting any feedback on the most important benefit in my proposed "Ideas for Python 3" thread - the unification of methods and functions. Perhaps it was buried among too many other less...
0
by: Ashish_khanna | last post by:
I have an MDI form. from here i am opening my child forms by creating objects. Plz tell me how to make single instance of these forms. and how to access ActiveMDI forms public methods
1
by: Christopher W. Douglas | last post by:
I'm working in VB.Net, using Visual Studio 2003. I have a project, let's call it Foo, that contains common methods, forms, and objects I use in other projects. It compiles as Foo.dll, which I...
2
by: Greg Merideth | last post by:
Using Visual C# I created two forms such as namespace test { public class SystemTray : System.Windows.Forms.Form { public createwindow() { stuff here; } public fadewindow() { stuff to fade...
3
by: thdevdex | last post by:
I'm new to the web forms world (ASP.Net) but not vb and am converting a vb6 windows app to the web. If I create public subroutines at a module level, is this a problem in a server based app? Will...
27
by: thomasp | last post by:
Variables that I would like to make available to all forms and modules in my program, where should I declare them? At the momment I just created a module and have them all declared public there. ...
4
by: Bugs | last post by:
Hi, I wonder if anyone can help me out. I'm building a vb.net application that has a form with a panel that contains several other sub forms (as a collection of controls). What I'm wanting to...
8
by: psema4 | last post by:
Hi all, I've spent several days trying to work this out. Maybe I'm just searching for the wrong keywords/phrases. I have some code that looks like: Console = new Object(); Console.init...
2
by: deepu | last post by:
Hello Everybody, I placed a toolbar on the MDIform . I want to declare some public functions in the individual forms and am trying to call these when ever a toolbar button is pressed. I worked...
7
by: Mark Chimes | last post by:
Hi All, I have multiple copies of the same form open in an app. (These are not MDI child forms). I then open a summary form that displays data from each of the previously open forms. I have a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.