Solved

Making the form update info while in a loop

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 …
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…

735 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