Home All Groups Group Topic Archive Search About

Problem with Display information in Labels

Author
11 Mar 2009 11:26 PM
Privado
Hi there,

I have develop an utility to scan through all the icons I have in my
computer in order to iliminate the ones that are identical.

The utility has a file control which holds the icon filenames. Then it runs
in a For/Next inside a Do/Loop processing all icons in there, starting from
the first one and the scanning from the next foward until last, repeating
the loop until it ends. There's also a label which shows me the counting.
There are about 20000 icons. After a while the counter stops showing but I
know the utility is running, since when it moves to the next icon, the
utility gets its focus. It all works fine except the display of the
information in the labels, which stops showing. I eaven added some refreshs
but with no result.

Sample of the code
(items started as LBL are labels, items started as LST are listboxs, items
started as FIL are fileboxs)

Private Sub Command3_Click()
    Command3.Enabled = False
    vpos = 0
    Do
        LBL_COUNTER.Caption = Format$(vpos, "##,###")
        For vi = vIndex + 1 To FIL_SOURCE.ListCount - 1
            vSourceBIN = FIL_SOURCE.Path + "\" + FIL_SOURCE.List(vIndex)
            vtargetbin = FIL_SOURCE.Path + "\" + FIL_SOURCE.List(vi)
            Open vSourceBIN For Binary As #1
            Open vtargetbin For Binary As #2
            LBL_STATUS.Caption = Format$(vi, "##,###") + "/" +
Format$(FIL_SOURCE.ListCount, "##,###")
            LBL_DELETEDSF.Caption = Format$(vErased, "##,###")
            LBL_INDEX.Caption = Format$(vIndex, "##,###")
            LBL_STATUS.Refresh
            LBL_DELETED.Refresh
            vsize1 = LOF(1)
            vsize2 = LOF(2)
            If vsize1 = vsize2 Then
                vBin1 = String$(vsize1, " ")
                vBin2 = String$(vsize2, " ")
                Get #1, 1, vBin1
                Get #2, 1, vBin2
                Close #1, #2
                REM here I make a binary compare. If they are the same the
add them to a listbox to be erased
                If vBin1 = vBin2 Then
                    LST_TOERASE.AddItem FIL_SOURCE.List(vi)
                End If
            End If
            Close #1, #2
        Next
        If LST_TOERASE.ListCount > 0 Then
            For vo = 0 To LST_TOERASE.ListCount - 1
                Kill FIL_SOURCE.Path + "\" + LST_TOERASE.List(vo)
                vErased = vErased + 1
            Next
        End If
        LST_TOERASE.Clear
        vIndex = vIndex + 1
        FIL_SOURCE.Refresh
        FIL_SOURCE.ListIndex = vIndex
        FIL_SOURCE.SetFocus
        Command3.Enabled = True
        vpos = vpos + 1
        If vpos = FIL_SOURCE.ListCount Then Exit Do
    Loop
End Sub

Does anyone has any sugestion on how to solve this?

Please post reply here.

Author
12 Mar 2009 12:00 PM
Bill McCarthy
Hi Privado,

Try putting in a DoEvents call to allow for painting.  But be aware that
DoEvents can let your code be called multiple times, eg the user clicks the
button again. Typically you guard against this by disabling buttons and/or
using a static variable in the function that you check to see if True and if
so exit, eg:

Private Sub Command3_Click()
  Static running As Boolean
  If running then Exit Sub
  running = True


  ....

  running = False
End sub


Show quoteHide quote
"Privado" <oceano.web***@netmadeira.com> wrote in message
news:49b8489d$0$14401$a729d347@news.telepac.pt...
> Hi there,
>
> I have develop an utility to scan through all the icons I have in my
> computer in order to iliminate the ones that are identical.
>
> The utility has a file control which holds the icon filenames. Then it
> runs in a For/Next inside a Do/Loop processing all icons in there,
> starting from the first one and the scanning from the next foward until
> last, repeating the loop until it ends. There's also a label which shows
> me the counting. There are about 20000 icons. After a while the counter
> stops showing but I know the utility is running, since when it moves to
> the next icon, the utility gets its focus. It all works fine except the
> display of the information in the labels, which stops showing. I eaven
> added some refreshs but with no result.
>
> Sample of the code
> (items started as LBL are labels, items started as LST are listboxs, items
> started as FIL are fileboxs)
>
> Private Sub Command3_Click()
>    Command3.Enabled = False
>    vpos = 0
>    Do
>        LBL_COUNTER.Caption = Format$(vpos, "##,###")
>        For vi = vIndex + 1 To FIL_SOURCE.ListCount - 1
>            vSourceBIN = FIL_SOURCE.Path + "\" + FIL_SOURCE.List(vIndex)
>            vtargetbin = FIL_SOURCE.Path + "\" + FIL_SOURCE.List(vi)
>            Open vSourceBIN For Binary As #1
>            Open vtargetbin For Binary As #2
>            LBL_STATUS.Caption = Format$(vi, "##,###") + "/" +
> Format$(FIL_SOURCE.ListCount, "##,###")
>            LBL_DELETEDSF.Caption = Format$(vErased, "##,###")
>            LBL_INDEX.Caption = Format$(vIndex, "##,###")
>            LBL_STATUS.Refresh
>            LBL_DELETED.Refresh
>            vsize1 = LOF(1)
>            vsize2 = LOF(2)
>            If vsize1 = vsize2 Then
>                vBin1 = String$(vsize1, " ")
>                vBin2 = String$(vsize2, " ")
>                Get #1, 1, vBin1
>                Get #2, 1, vBin2
>                Close #1, #2
>                REM here I make a binary compare. If they are the same the
> add them to a listbox to be erased
>                If vBin1 = vBin2 Then
>                    LST_TOERASE.AddItem FIL_SOURCE.List(vi)
>                End If
>            End If
>            Close #1, #2
>        Next
>        If LST_TOERASE.ListCount > 0 Then
>            For vo = 0 To LST_TOERASE.ListCount - 1
>                Kill FIL_SOURCE.Path + "\" + LST_TOERASE.List(vo)
>                vErased = vErased + 1
>            Next
>        End If
>        LST_TOERASE.Clear
>        vIndex = vIndex + 1
>        FIL_SOURCE.Refresh
>        FIL_SOURCE.ListIndex = vIndex
>        FIL_SOURCE.SetFocus
>        Command3.Enabled = True
>        vpos = vpos + 1
>        If vpos = FIL_SOURCE.ListCount Then Exit Do
>    Loop
> End Sub
>
> Does anyone has any sugestion on how to solve this?
>
> Please post reply here.
>
>