Solved

Making the form update info while in a loop

Posted on 2006-07-10
1
166 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

734 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