473,487 Members | 2,680 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Declare public variable in C#1

I am beginner in using C#, actually I am trying to move from VB6 to C#
I need very small maybe you will laugh when you get it that simply I have 2
forms let’s say Form1 (main form) and Form2 and there is parameter in form2 I
have to call from form1.
So please would you tell me how?
What I tried is like this
//I call public variable lets say SqlReportPar in Form1

Public string SqlReportPar;

//Then go to Form2
Form test=new Form1();
Test. //(the SqlReportPar does not appear) why?????

//What happened!
Form test=new Form1(). //(the SqlReportPar appear here )!!!!!
Test. //(the SqlReportPar does not appear) why?????

Any way thanks

Nov 17 '05 #1
1 1434
The type of test in your code is Form not Form1.

Try:

Form1 test = new Form1();
test.

Christof

"MMSJED" <MM****@discussions.microsoft.com> schrieb im Newsbeitrag
news:19**********************************@microsof t.com...
I am beginner in using C#, actually I am trying to move from VB6 to C#
I need very small maybe you will laugh when you get it that simply I have
2
forms let's say Form1 (main form) and Form2 and there is parameter in
form2 I
have to call from form1.
So please would you tell me how?
What I tried is like this
//I call public variable lets say SqlReportPar in Form1

Public string SqlReportPar;

//Then go to Form2
Form test=new Form1();
Test. //(the SqlReportPar does not appear) why?????

//What happened!
Form test=new Form1(). //(the SqlReportPar appear here )!!!!!
Test. //(the SqlReportPar does not appear) why?????

Any way thanks

Nov 17 '05 #2

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

Similar topics

8
1946
by: Johm | last post by:
In my codes i am often referring to one and the same controls.Is it possible to declare these controls only once and then insert them in all my functions and subs? For example, i am often...
5
33062
by: MMSJED | last post by:
I am beginner in using C#, actually I am trying to move from VB6 to C# I need very small help in programming problem my be you will laugh when you get it That simply I have to form let’s say...
15
5299
by: Geoff Cox | last post by:
Hello, Can I separately declare and initialize a string array? How and where would I do it in the code below? It was created using Visual C++ 2005 Express Beta 2 ... In C# I would have ...
2
1177
by: Jul | last post by:
Hi, Maybe configuration for getting the same result can be simpler but I will describe my real one. I have one solitions which contains 2 projects: Class Lib and WinApp. Class Lib define...
2
11077
by: Mamatha | last post by:
Hi If any one knows,please tell me how can we declare a public variable in methods of VB.NET like public indx as integer. How can i use that variable in another methods like global...
6
2110
by: **Developer** | last post by:
Notice below I sometimes used the "A" version. I found by cut-and-try that only the "A" version would work correctly. Anyone have a suggestion of why the "W" version would not work correctly? ...
4
2817
by: ankurdave | last post by:
Is it possible to declare a class member variable in the constructor? For example, class SomeClass { public: SomeClass() { int SomeArray; } }
15
2966
by: esha | last post by:
I need to have a Public variable in my project. In VB it can be declared in a standard module. Where can I do it in C# ? I tried to do it in default class Program.cs and I tried it in an added by...
0
8289
by: roamnet | last post by:
hi i created database file with .mdf extention ,sql server as a source and use grid view to display data there're no problem in data retrieve and display,but i want to edit it or insert new...
1
3868
by: yu83thang | last post by:
Hi, May I know how to declare a Class in C++ window application form? Below is my code and error as shown below as well. here is my class declaration: ref class CLoadObj { public:
0
7106
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7137
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,...
1
6846
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
5442
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 project—planning, coding, testing,...
1
4874
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...
0
4565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1381
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
600
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.