Access The Result Of A Function Called In A Splash Screen

Hi,

My application currently has three classes - MainForm.vb, SplashScreen.vb and a user-created class Server.vb. In the latter class, I have a function which pings a server (at the moment I'm just using the Google IP as I will get a "True" result). When my splash screen is shown, the function is called so the user is informed if the server can be reached. What I want to do is access the result of this function in my MainForm load event (at the moment I'm just using a Button click event) without having to call the function again.

I've tried putting a public variable in my MainForm.vb class which the splash screen changes according to the result of function - this didn't work. I've also tried putting a public variable in my Server.vb class and having the splash screen change this, then having the MainForm get the variable result from the Server.vb class without creating a new instance, but that didn't work either.

Does anyone know how I can do this without having to call the function twice or saving data to a file

Thanks.

(Code For Server.vb):

Public Class Server

Public ConnectError As Boolean

Public Function ConnectToServer(ByVal UpdateConnectError As Boolean) As Boolean

If My.Computer.Network.Ping("82.32.194.64") = True Then

Return True

If UpdateConnectError = True Then

ConnectError = False

End If

Else

Return False

If UpdateConnectError = True Then

ConnectError = True

End If

End If

End Function

End Class



Answer this question

Access The Result Of A Function Called In A Splash Screen

  • KrazyMGA

     

    There are lots of ways to do this....

    But it seems to me that the easiest way to do it is to have a common module:

    Public Module Foo

    Public PingResult as boolean

    End Module

     

    Public Sub ConnectToServer(ByVal UpdateConnectError As Boolean)

               PingResult = My.Computer.Network.Ping("82.32.194.64")

    additional code follows

    End sub

     

     



  • Access The Result Of A Function Called In A Splash Screen