?
Solved

Message Passing between 2 classes

Posted on 2003-03-06
7
Medium Priority
?
214 Views
Last Modified: 2010-04-17
I have a single program. Class A reads messages from a control box. I need to display this message on my dialog box(class B). Hence i create an instance of A in B. Now i need A to pass the message to B. Currently i have a fnction with a flag that i loop(in class B). Once a message is available in class A, class B reads the message and resets the flag. Is there a more efficient way to do this.
Thanks,
Anthony
0
Comment
Question by:antiwong
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
7 Comments
 

Expert Comment

by:Jayhpot
ID: 8086308
i think placing the message to a global variable will do the trick... both classes will recognize the value of that variable
0
 

Accepted Solution

by:
CoenMeerbeek earned 100 total points
ID: 8087981
Is this what you mena?

Class A
{
  public String getString()
  {
     return TextBox.text;
  }
}

Class Main
{
  A a = new A();
  B b = new B();

  String s = a.getString();

  b.setString(s);
}

Class B
{
  private String str;

  public setString(String s)
  {
    str = s;
  }
}

Good luck
0
 

Expert Comment

by:CoenMeerbeek
ID: 8087989
Is this what you mena?

Class A
{
  public String getString()
  {
     return TextBox.text;
  }
}

Class Main
{
  A a = new A();
  B b = new B();

  String s = a.getString();

  b.setString(s);
}

Class B
{
  private String str;

  public setString(String s)
  {
    str = s;
  }
}

Good luck
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Assisted Solution

by:Jayhpot
Jayhpot earned 100 total points
ID: 8093251
well, i don't know what language u are using but whatever it is, i know it has a capability to declare a global/public variable which any class or function can use.

in vb, we create a global module (ex: modGlobal.bas) declaring all global variables in our program.

ex:

Global strMessage As String

that variable is accessible to any class/function/procedure.

ex:

function initial(){
   strMessage = text1.text
}


function getMsg(){
   label1.caption = strMessage
}

0
 

Expert Comment

by:CleanupPing
ID: 9447295
antiwong:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 

Expert Comment

by:Jayhpot
ID: 9448714
since i'm the only one who answered it, i might as well recommend that my answer be accepted
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Six Sigma Control Plans
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question