TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Tony
NA
30
0
Trying to retrieve a variable from a program.
Dec 17 2009 1:13 PM
I have a form (form1.cs) that sends a transaction record variable (TranRec) to a program (Transporter.cs) by calling it using Transporter.ConnectToDMV(TranRec);.
Transporter.cs does what it needs to do and returns to form1.cs for the user to enter and submit another transaction. Here's part of the Transporter.cs code.
Transporter.cs
public partial class Transporter
{
public static void ConnectToDMV(string TranRec)
{ rest of code processing TranRec ...
What I also need Transporter.cs to do is return a variable (logLU) back to form1.cs. For this I am using the following code;
Transporter.cs
Form1 aForm = new Form1();
aForm.SetValue(logLU);
form1.cs
public void SetValue(string luValue)
{
logLU = luValue;
// for testing purposes
MessageBox.Show("Here's the value of (form1)luValue: " + luValue);
MessageBox.Show("Here's the value of (form1)logLU: " + logLU);
}
I can see both variables in the messageboxes so I know logLU gets to form1.cs but then it returns to null when I need it in other parts of form1.cs. What am I missing??? Similar code works in other parts of my program but not here. BTW, I'm a newbie to C# and this is my first application.
Any advise will be very much apprecaited.
Reply
Answers (
7
)
int in c#
how to trigger an event from the code in c#?