none
Display text form 1 project to another project.

    Question

  • Hi please bear me for asking as I am a newbie .

    I am asked to write 2 identical programs (chat like application) that needs to communicate to each other. When the first program sends a message  the second program must detect the file in the folder (where message of program 1 saved) and must display it. 
    Any idea ?

    Thank you very much in advance. A sample code will be much appreciated.

    Friday, April 21, 2017 1:47 AM

All replies

  • Hi. 

    Please help. I have two project  (Project A and B) that I need them to communicate to each other (Chat like app). I can display the form from project B . How ever when I try to pass data from Project a it gives me error "reference to a non shared member requires an object reference". Eventhough I have add the project b to reference. Please see my codes below:

    Private Sub ShowChatFormOfRecipient()

            If CurrentRecipient = "Edward" Then

                If Not (Application.OpenForms().OfType(Of DecaMessengerReceiverForm).Any) Then
                    DecaMessengerReceiverForm.Show()
                End If


                Dim NewUnsortedList As ArrayList = GetFileNamesToUnorderedList(CurrentRecipient)
                Dim NewSortedList As List(Of FileName) = SortFiles(CurrentRecipient, NewUnsortedList)
                Dim messages As String

                For Each name As FileName In NewSortedList
                    Dim fileReader As String
                    fileReader = My.Computer.FileSystem.ReadAllText(RecipientFolder + name.Id.ToString("MMddyyyyhhmmss") + ".txt")

                    If messages = "" Then
                        messages = fileReader

                    Else
                        messages = messages + Environment.NewLine + fileReader
                    End If


                Next
                DecaMessengerReceiverForm.ShowtextRichTextBoxReceiver.Text = messages

    Thursday, April 20, 2017 7:22 AM
  • If you want to create a Chat application, you may want to look at TCP/IP and  this thread will start you up https://www.codeproject.com/Articles/38914/A-TCP-IP-Chat-Program

    If you just want to pass data between forms you could create a data object with events to change the text in the receiving form, but that limits to your own screen...

    So what is it you are going to write?


    Thursday, April 20, 2017 8:11 AM
  • Thank you for your reply. Well I just need to pass data from project 1 to project 2. Please help :(
    Thursday, April 20, 2017 11:29 PM
  • How ever when I try to pass data from Project a it gives me error "reference to a non shared member requires an object reference".

    What is the line of code where the error occurs, and what is the variable that the message refers to?

    Friday, April 21, 2017 12:08 AM
  • sorry for that. Well there has been a miscommunication. What I need to do is create 1 program and copy this to another . then they have to communicate. :( Please help
    Friday, April 21, 2017 2:07 AM
  • Please answer the question from your original thread.

    Friday, April 21, 2017 2:20 AM
  • I have now removed this. As I was instructed not to call the second program. I need an identical program that runs at the same time. Any idea how to do this ?
    Friday, April 21, 2017 2:26 AM
  • I have now removed this. As I was instructed not to call the second program. I need an identical program that runs at the same time. Any idea how to do this ?

    Removed what?  If you are no longer using the code you originally posted then you need to show the code you are now using.

    If you want an idea of how to communicate between two identical programs, take the suggestion already offered above : https://www.codeproject.com/Articles/38914/A-TCP-IP-Chat-Program

    Friday, April 21, 2017 2:52 AM
  • Hi Bhelle,

    Are the two projects in the same solution? If they are in the same solution you should be able to add reference one another given their namespaces. Just add a "Imports" directive in one project that brings in the namespace in the other project and you should be able to access code in the other project.

    For example, I create one solution and two project, one is Test1, another is Test2.

    On Test1.s Form1, I add one function

     Public Function testmethos() As String
            Return "test"
        End Function

    An then I right-click Test2 reference---Add Reference...---Projects---choose Test1, now I can call Test1's function on the Test2's Form2.

    Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Dim a As New Test1.Form1
            MessageBox.Show(a.testmethos)
        End Sub

    Hope it is helpful to you.

    Best Regards,

    Cherry Bu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.





    Friday, April 21, 2017 2:57 AM
    Moderator