Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7842049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:13:49+00:00 2026-06-02T16:13:49+00:00

Public Shared _formRef As frmMain Public Shared f As frmMain Class Server <STAThread()> Public

  • 0
Public Shared _formRef As frmMain
Public Shared f As frmMain

    Class Server
        <STAThread()> Public Shared Sub Main()
            Dim aTcpMessaging As IMessagingSystemFactory = New TcpMessagingSystemFactory()
            Dim anInputChannel As IInputChannel = aTcpMessaging.CreateInputChannel(theIPforLocal & ":" & thePort)
            Dim aStringMessagesFactory As IStringMessagesFactory = New StringMessagesFactory()
            Dim aStringMessageReceiver As IStringMessageReceiver = aStringMessagesFactory.CreateStringMessageReceiver()
            AddHandler aStringMessageReceiver.MessageReceived, AddressOf StringMessageReceived

            aStringMessageReceiver.AttachInputChannel(anInputChannel)
        End Sub

        Private Shared Sub StringMessageReceived(ByVal sender As Object, ByVal e As StringMessageEventArgs)
            _formRef = f

            LANResponse = Convert.ToString(e.Message)
            Dim lanSent As String() = Nothing
            Dim sep(3) As Char
            Dim s As String = ""

            sep(0) = "~"
            'sep(1) = ","
            lanSent = LANResponse.Split(sep, 2)

            Dim a As New Threading.Thread(AddressOf getStatus)

            a.SetApartmentState(Threading.ApartmentState.STA)
            a.Start(Trim(lanSent(0)) & Trim(lanSent(1)))
   End Sub
End Class

Class Sending
        Public Shared Sub Main(ByRef whatToWrite As String)
            Dim aTcpMessaging As IMessagingSystemFactory = New TcpMessagingSystemFactory()
            Dim anOutputChannel As IOutputChannel = aTcpMessaging.CreateOutputChannel(theIPforVM & ":" & thePort)
            Dim aStringMessagesFactory As IStringMessagesFactory = New StringMessagesFactory()
            Dim aStringMessageSender As IStringMessageSender = aStringMessagesFactory.CreateStringMessageSender()

            aStringMessageSender.AttachOutputChannel(anOutputChannel)
            aStringMessageSender.SendMessage(whatToWrite)
        End Sub
End Class

    Private Shared Sub getStatus(ByVal data As Object)
        _formRef.UpdateLabelText("Static: " & data)
    End Sub

    Public Sub UpdateLabelText(ByVal text As String)
        If Me.lblStatus.InvokeRequired Then
            Me.lblStatus.Invoke(New Action(Of String)(AddressOf UpdateLabelText), New Object() {text})
        Else
            Me.lblStatus.Text = text
        End If
    End Sub

#Region "Form Load"
    <STAThread()> Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Call Server.Main()
        '--------------------------------
        isTesting = False
        lblVer.Text = "V.7"
        '--------------------------------
    End Sub
#End Region

but once firing off the code i get the error you see in my image attached

error

But oddly enough i do pass the value i am looking for:

error 2

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T16:13:52+00:00Added an answer on June 2, 2026 at 4:13 pm

    You never assign the running instance of frmMain to the shared variables.

    If you change your Server Main method to:

        <STAThread()> Public Shared Sub Main(formRef As frmMain)
            f = FormRef
    

    and then change your call to this method to:

    Call Server.Main(Me)
    

    Then that should solve your problem (assuming Server.Main is called from frmMain).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

sample.vb class sam public shared sub hh() Console.WriteLine(asasas) end sub end class test.vb Dim
I run the following code snippet. Public Shared Sub DisplayDnsConfiguration() Dim adapters As NetworkInterface()
I've got a class like this: Public NotInheritable Class F Private Sub New() End
Given the following code Public Shared Sub DoAsyncAction() Using asmxProxy As New MyAsmxServiceProxy() AddHandler
Public Shared Function GetData(ByVal id As Integer) As List(Of SomeClass) Dim command As New
web method: <WebMethod()> Public Shared Function Pcpacking() As IEnumerable(Of Packing) Dim db As New
I have a utility class that creates & returns a db connection: Public Shared
I have the following Repository: Public Class PageRepository Private Shared _pages As BLL.PageCollection Shared
I have the following classes: Public Class Email Private Shared ReadOnly EMAIL_REGEX = \b[a-zA-Z]+[a-zA-Z0-9._+-]+@
This is what I am talking about: Public Shared Sub Test1() Test2() End Sub

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.