473,406 Members | 2,549 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,406 software developers and data experts.

VB programer having a C# newby question...

Hi,

In Visual Basic there are modules where I can store public variables, Constants, etc.
I have in a C# program a class that have a method to open a form.

public void GUIGestaoAcessos(string sDBUser, string sDBPassw, string sDBDsn)
{
Form oform=new FrmSeguranca();
oform.Show(); //He will connect to DB using the method parameters...
}

How can I pass the method parameters (string sDBUser, string sDBPassw, string sDBDsn) into the form so that He can use them...

Thanks for your help,
Bernardo
Nov 15 '05 #1
2 1089
Use the constructor of the Form. You can (just like any other 'function')
overload it.

So you should get something like :

FrmSeguranca oform = new FrmSeguranca(sDBUsern DBPassw, sDBDsn); // notice
i'm not using Form here
oform.Show();

And then in your class FrmSeguranca you have the following

class FrmSeguranca {
// some things like private variables, other constructors, ...

// The constructor you wish to use
public FrmSeguranca(string username, string password, string dsn)
{
// and here you do your connection
}
}

HTH

Yves

"Bernardo" <bp****@sapo.pt> schreef in bericht
news:68**********************************@microsof t.com...
Hi,

In Visual Basic there are modules where I can store public variables, Constants, etc. I have in a C# program a class that have a method to open a form.

public void GUIGestaoAcessos(string sDBUser, string sDBPassw, string sDBDsn) {
Form oform=new FrmSeguranca();
oform.Show(); //He will connect to DB using the method parameters...
}

How can I pass the method parameters (string sDBUser, string sDBPassw, string sDBDsn) into the form so that He can use them...
Thanks for your help,
Bernardo

Nov 15 '05 #2
Hi Bernardo

There are some ways to do that

You can pass that parameters to FrmSeguranca class constructor

public void FrmSeguranca(string sDBUser, string sDBPassw, stringsDBDsn

..... now you can use the sDBUser and rest of the fields her
and then you can initialize your form in that way

public void GUIGestaoAcessos(string sDBUser, string sDBPassw, string sDBDsn

Form oform=new FrmSeguranca(sDBUser, sDBPassw, sDBDsn)
oform.Show(); //He will connect to DB using the method parameters..
or you can declare properties in FrmSeguranca class

class FrmSeguranca(

private string sDBUser
public string sDBUse

get

return sDBUser

se

sDBUser = value

... rest of FrmSeguranca class cod
Now you can use that properties

public void GUIGestaoAcessos(string sDBUser, string sDBPassw, string sDBDsn

Form oform=new FrmSeguranca()
oform.sDBUser = sDBUser
oform.Show(); //He will connect to DB using the method parameters..
Hope this helps

Cheers
Chri

Nov 15 '05 #3

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

Similar topics

9
by: Damien | last post by:
I have just built a simple stopwatch application, but when i f5 to get things goings i get this message, An unhandled exception of type 'System.ArithmeticException' occurred in...
0
by: Pete | last post by:
Hi All, A total Newby with, possibly, a daft question? However, until I can get a reasonable explanation I am disinclined towards going further. Here goes: I recently downloaded the latest...
8
by: Ask | last post by:
G'day All, Just thought I'd drop in and say hi. I'm new to Python, but old to software development. Python is one of the languages used in my new job, so I've just bought a book, read it, and...
11
by: Harsimran | last post by:
I am a young C programer and want to increase my knowledge in C and also Like to get some money not more just a little .If u can help in getting me my pocket money or can help me in gaining my...
10
by: Fred Nelson | last post by:
Hi: I have programmed in VB.NET for about a year and I'm in the process of learing C#. I'm really stuck on this question - and I know it's a "newby" question: In VB.NET I have several...
4
by: Fred Nelson | last post by:
I have an applicatioin that I'm writing that uses a "case" file that contains over 350 columns and more may be added in the future. I would like to create a dataset with all the column names and...
4
by: Fred Nelson | last post by:
Hi: I'm developing a web application that needs to have five values, each retrieved from cookies on many pages. If I have five "Request.Cookies" commands together does this cause five "round...
2
by: Fred Nelson | last post by:
Hi: I'm working on a VS2005 web application and I have what is probabably a "newby" question. In VS2003 I could drag a textbox/button/etc on to a form and position it with the mouse. I...
10
by: Charles Russell | last post by:
Why does this work from the python prompt, but fail from a script? How does one make it work from a script? #! /usr/bin/python import glob # following line works from python prompt; why not in...
15
by: Xah Lee | last post by:
2007-03-29 Dear tech geekers, In a couple of posts in the past year i have crossed-posted (e.g. recently “What are OOP's Jargons and Complexities”, “is laziness a programer's...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.