How to get data from aplication open forms (WindowsApplication.exe) ?

Hello,
I'm trying to solve how to get data from open application windows. For example, if user is login into as John, and another one as Paul. Of course both has open same application, but with different names, and with same control lblMembers from behind script.

I would like somehow that Server form get both names on Listbox, or similar.
I have try with code from Server Form, but of course not working.

Thank you in advance for help to anyone.

Codes:
Login form:
Public Class Login

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If txtUsername.Text = "john" Or txtUsername.Text = "paul" Then
            MsgBox("Welecome " & txtUsername.Text.ToUpper)
            Clients.Show()
            Me.Hide()
        ElseIf txtUsername.Text = "admin" Then
            MsgBox("Welecome " & txtUsername.Text.ToUpper)
            Server.Show()
            Me.Hide()
        Else
            MsgBox("Invalid username. Please, try again")
        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Application.Exit()
    End Sub
End Class

Open in new window


Client form:
Public Class Clients

    Private Sub Clients_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        lblMember.Text = WindowsApplication1.Login.txtUsername.Text.ToUpper
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Application.Exit()
    End Sub
End Class

Open in new window


Server form:
Public Class Server

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ListMembers.Text = WindowsApplication1.Clients.lblMember.Text

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Application.Exit()
    End Sub
End Class

Open in new window

PrintScreen.JPG
dejandejanovicAsked:
Who is Participating?
 
dejandejanovicConnect With a Mentor Author Commented:
Idle_Mind, you are right. In any case I will need test it, or over LAN, or Internet.
0
 
Mike TomlinsonConnect With a Mentor Middle School Assistant TeacherCommented:
Are all these forms being displayed from the same instance of the application?
...or from multiple instances being run?

Are they all going to be running on the same machine?

I'm confused because line #6 in your Login form would allow only one instance of the Clients form to be displayed at once...
...so you must have more than instance of the application open.

But line #4 in your Server form is attempting to access the default instance of Clients that is running in the same instance.

Describe the big picture of how this system will be used.
0
 
dejandejanovicAuthor Commented:
In my case, yes, only from one instance. At the moment I'm just learning, so I'm just testing on one machine.

I have replace ListBox with Label control just to see what I will get, and I have got a default label text Label1, and not a result such as login name ?!



PrintScreen.JPG
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Ok...but the techniques used to get the values from Forms in the same application are completely different from those used to get values from Forms running in a different instances.

Furthermore, retrieving values from instances running on a different machine would also be different.

Thus the questions about how the end system is going to be used.  Going down the route you've started is probably pointless as it can't be translated to communication across a network or the internet.
0
 
dejandejanovicAuthor Commented:
Can you please give me some tips which method to use, where to start, or something?
Thanks
0
 
vastoConnect With a Mentor Commented:
Dejan, check these 2 examples:
http://www.codeproject.com/KB/WCF/WCFWPFChat.aspx
http://www.codeproject.com/KB/WCF/Chat_application_using_WC.aspx

You can google for "WCF chat" to find more examples.
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Are you going to communicate only with machines behind a firewall?...or across the internet?

Again, what your end product is supposed to do ditactes what technologies can be used and how they must be employed.
0
 
dejandejanovicAuthor Commented:
topic close
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.