Percentage durin loop

User avatar
sal21
PlatinumLounger
Posts: 4362
Joined: 26 Apr 2010, 17:36

Percentage durin loop

Post by sal21 »

Code: Select all


Private Sub APRI_TAB()

    Dim I As Long

    Me.LAZIONI.Caption = "EXPORT DATI...!"
    DoEvents

    Set RSA = New ADODB.Recordset
    RSA.CursorLocation = adUseClient
    RSA.Open SQL, CNN, adOpenForwardOnly, adLockReadOnly
    NR = RSA.RecordCount

    Erase strDBRows()
    strDBRows = RSA.GetRows()
    RSA.Close
    Set RSA = Nothing
    
    R = 1

    For I = 0 To UBound(strDBRows, 2)

        Me.LPERCENT.Caption = NR / R * 100 & "%"
        
        DoEvents
        R = R + 1

    Next I

    Me.LAZIONI.Caption = "FINE EXPORT DATI!"
    DoEvents
    Sleep (1000)
    Me.LAZIONI.Caption = ""
    DoEvents

End Sub
...i'm not sure.
In label i see a big number with 9 decimal !!!!

R and NR as Long dimensioned

User avatar
HansV
Administrator
Posts: 78534
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Percentage durin loop

Post by HansV »

Change the line

Code: Select all

        Me.LPERCENT.Caption = NR / R * 100 & "%"
to

Code: Select all

        Me.LPERCENT.Caption = Format(NR / R, "0%")
Best wishes,
Hans