Solved

Making the form update info while in a loop

Posted on 2006-07-10
1
163 Views
Last Modified: 2010-05-18
I have a ping program that I created from some example code.  I can't seem to make it update the progress on the form while it is inside this loop.  I would also like to be able to click a button on the form to cancel this loop, but the program acts locked up until it finishes this loop.  See below.  

For IPloop = intIP4 To intIP5
      txtipaddress = intIP1 & "." & intIP2 & "." & intIP3 & "." & IPloop
      If SocketsInitialize() Then
        'ping the ip passing the address, text
        'to send, and the ECHO structure.
        success = Ping(txtipaddress, "Test", ECHO)
        'display the results
        If chkDifferentWindow.Value = Unchecked Then
          If success = 0 Or chkDisplayResults.Value = Checked Then
            PingOutput.SelStart = 65535
            If chkHostname.Value = Unchecked Then
              PingOutput.SelText = txtipaddress + GetStatusCode(success) + Chr$(13) + Chr$(10)
            Else
              If success = 0 Then
                PingOutput.SelText = txtipaddress + "  " + GetHostNameFromIP(txtipaddress) + Chr$(13) + Chr$(10)
              Else
                PingOutput.SelText = txtipaddress + "  " + GetStatusCode(success) + Chr$(13) + Chr$(10)
              End If
            End If
          End If
        Else
        If success = 0 Then
          PingOutput.SelStart = 65535
          If chkHostname.Value = Unchecked Then
            PingOutput.SelText = txtipaddress + GetStatusCode(success) + Chr$(13) + Chr$(10)
          Else
            PingOutput.SelText = txtipaddress + "  " + GetHostNameFromIP(txtipaddress) + Chr$(13) + Chr$(10)
          End If
        Else
          pingOutput2.SelStart = 65535
          pingOutput2.SelText = txtipaddress + GetStatusCode(success) + Chr$(13) + Chr$(10)
        End If
      End If
      SocketsCleanup
    Else
      MsgBox "Windows Sockets for 32 bit Windows " & "environments is not successfully responding."
    End If
    Next IPloop
0
Comment
Question by:Tom_Hickerson
1 Comment
 
LVL 45

Accepted Solution

by:
aikimark earned 250 total points
ID: 17076618
after changing a property of a control on the form, such as label.caption or textbox.text, you should do a me.refresh.

You would also do well to include a DoEvents statement along with the update.

Instead of doing this update for every iteration, you might only do the update every N iterations.  For this use
If (IPLoop Mod N) = 0 Then
  'form update statements
End If
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SSRS expression Issue finding a string 10 79
message box in access 4 47
vb6 connector to mongodb 2 85
Error with a code discussed on this page 5 16
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question