Solved

Making the form update info while in a loop

Posted on 2006-07-10
1
161 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…

705 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now