Hi All,

I am currently making a server monitoring application that pings the server to check its uplink, so far it creates all the picture boxes and labels for each server, and then pings the server, although I have a picture that I want to change dependant on the result.

Below is the code I am currently using, the problem occurs with the objectname variable which allows dynamic coding, where i get a error, saying that "Public member 'image' on type 'String' not found".

Private Sub Ping()
        Dim i As Integer
        Dim objectName As System.Object
        For i = 1 To count - 1

            Dim pingSender = New Ping()

            'Send the packet with a 1500ms timeout

            Dim reply As PingReply = pingSender.Send(servers(2, i), 1500)

            'Output the reply in the appropriate colour depending on RoundtripTime
            objectName = "pic" + servers(1, i)
            If reply.Status = IPStatus.Success Then

                If (reply.RoundtripTime <= 200) Then
                    objectName. = My.Resources.Online

                ElseIf (reply.RoundtripTime > 200 & reply.RoundtripTime <= 600) Then
                    objectName.Image = My.Resources.Problem
                End If

                objectName.Image = My.Resources.Offline
            End If
    End Sub

Can anyone see where I have gone wrong?

Thanks in Advance


7 Years
Discussion Span
Last Post by CallumP93

You've gone wrong at objectname = "pic" + servers(1,i)

Looks like your wanting to assign a picturebox to objectname but only assigning the name of the picturebox.

What is servers?


Servers is the array holding server names,

i need to be able to change the picmysql picture etc without habving to hard code it

'Assuming the name of your picbox's 
        'corresponds to the server name
        'and the picturebox's are added to the

        Dim ObjectName As String = "pic" '+ servers(1,i)

        Dim p As PictureBox

        If Me.Controls.ContainsKey(ObjectName) Then
            p = Me.Controls(ObjectName)
            'exit sub
        End If

        'p.Image = My.Resources.xxx
Votes + Comments
A simple effective solution to my problem.
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.