Visualizzazione dei risultati da 1 a 10 su 10
  1. #1
    Utente di HTML.it
    Registrato dal
    Oct 2002
    Messaggi
    752

    [VB6] Domanda da principiante

    Ciao
    Ho questo codice :

    Do
    FileInfo = GetFileName(DirInfo(iPos).lpBuffer, lPointer)
    strPath = Trim(DirInfo(iPos).lpszDirName) & "\" & FileInfo.Name
    Dim Add
    Select Case FileInfo.Type
    Case FILE_ACTION_ADDED
    Add = 10
    strmsg = "[" & strPath & "] was added to the directory."
    Case FILE_ACTION_REMOVED
    strmsg = "[" & strPath & "] was removed from the directory."
    Case FILE_ACTION_MODIFIED
    Add = Add + 1
    strmsg = "[" & strPath & "] was modified..."
    Case FILE_ACTION_RENAMED_OLD_NAME
    strmsg = "[" & strPath & "] was renamed and this is the old name."
    Case FILE_ACTION_RENAMED_NEW_NAME
    strmsg = "[" & strPath & "] was renamed and this is the new name."
    End Select

    Ho la variabile ADD che quando passa da "Case FILE_ACTION_ADDED" diventa valore =10.
    Poi quando passa da "Case FILE_ACTION_MODIFIED" dovrebbe additivarsi di 1.
    Non capisco perchè perde il valore 10 e quando passa da "Case FILE_ACTION_MODIFIED" somma sempre da 1, come se una volta finito "Case FILE_ACTION_ADDED" resettasse il valore di ADD.
    Comunque Grazie

  2. #2
    Utente di HTML.it L'avatar di oregon
    Registrato dal
    Jul 2005
    residenza
    Roma
    Messaggi
    36,480
    Beh ... la

    Dim Add

    sta all'interno del ciclo, quindi ...
    No MP tecnici (non rispondo nemmeno!), usa il forum.

  3. #3
    Utente di HTML.it
    Registrato dal
    Oct 2002
    Messaggi
    752
    Ciao e grazie.
    Adesso ho messo la mia Dim all'inizio della Sub dove dichiaro tutte le variabili ma la cosa non cambia.

    Ti chiedo un pochino di pazienza e aiuto.
    Comunque Grazie

  4. #4
    Utente di HTML.it L'avatar di oregon
    Registrato dal
    Jul 2005
    residenza
    Roma
    Messaggi
    36,480
    Mi mostri tutta la Sub, dall'inizio alla fine?
    No MP tecnici (non rispondo nemmeno!), usa il forum.

  5. #5
    Utente di HTML.it
    Registrato dal
    Oct 2002
    Messaggi
    752
    Private Sub HandleDirectoryChanges()
    On Error Resume Next

    Dim fContinue As Boolean
    Dim lPointer As Long, iPos As Integer
    Dim lngCompKey As Long
    Dim lpOverlapped As OVERLAPPED
    Dim fni As FILE_NOTIFY_INFORMATION
    Dim DI As DIRECTORY_INFO
    Dim FileInfo As FileChange
    Dim Add

    '// Retrieve the directory info for this directory
    '// through the completion key
    ret = GetQueuedCompletionStatus(hIOCompPort, _
    lpBytesReturned, _
    lngCompKey, _
    oOverLapped, _
    100) '//Put INFINITE if synchronous

    If (ret <> 0) Then
    lPointer = 0

    '//Findout which directory is this based on completionkey
    For iPos = 0 To numDirs - 1
    If DirInfo(iPos).lComplKey = lngCompKey Then Exit For
    Next

    Do
    FileInfo = GetFileName(DirInfo(iPos).lpBuffer, lPointer)
    strPath = Trim(DirInfo(iPos).lpszDirName) & "\" & FileInfo.Name
    Select Case FileInfo.Type
    Case FILE_ACTION_ADDED
    Add = 10
    strmsg = "[" & strPath & "] was added to the directory."
    Case FILE_ACTION_REMOVED
    strmsg = "[" & strPath & "] was removed from the directory."
    Case FILE_ACTION_MODIFIED
    Add = Add + 1
    strmsg = "[" & strPath & "] was modified..."
    Case FILE_ACTION_RENAMED_OLD_NAME
    strmsg = "[" & strPath & "] was renamed and this is the old name."
    Case FILE_ACTION_RENAMED_NEW_NAME
    strmsg = "[" & strPath & "] was renamed and this is the new name."
    End Select

    List2.AddItem strmsg & "Add è = " & Add

    lPointer = FileInfo.NextPos

    Loop While (lPointer > 0)

    ret = ReadDirectoryChangesW(DirInfo(iPos).hDir, _
    DirInfo(iPos).lpBuffer(0), _
    MAX_BUFFER, _
    bWatchSubDir, _
    lngFilter, _
    lpBytesReturned, _
    DirInfo(iPos).oOverLapped, _
    ByVal 0&)
    End If

    End Sub
    Comunque Grazie

  6. #6
    Utente di HTML.it L'avatar di oregon
    Registrato dal
    Jul 2005
    residenza
    Roma
    Messaggi
    36,480
    Subito dopo Add = 10 e subito dopo Add = Add + 1 scrivi

    Debug.Print Add

    ed esegui il programma.

    Controlla nella finestra di debug, quali valori sono visualizzati ...
    No MP tecnici (non rispondo nemmeno!), usa il forum.

  7. #7
    Utente di HTML.it
    Registrato dal
    Oct 2002
    Messaggi
    752
    Per questo ti chidevo molta pazienza.
    La riga l'ho messa ma non so dov'è la finestra di debug.
    Comunque Grazie

  8. #8
    Utente di HTML.it L'avatar di oregon
    Registrato dal
    Jul 2005
    residenza
    Roma
    Messaggi
    36,480
    Originariamente inviato da fosforo
    Per questo ti chidevo molta pazienza.
    La riga l'ho messa ma non so dov'è la finestra di debug.
    Ctrl-G ... la finestra immediata ...
    No MP tecnici (non rispondo nemmeno!), usa il forum.

  9. #9
    Utente di HTML.it
    Registrato dal
    Oct 2002
    Messaggi
    752
    Grazie
    In realtà mi ero sbattuto e l'avevo trovata.
    Stampa

    10
    1
    2
    Comunque Grazie

  10. #10
    Utente di HTML.it L'avatar di oregon
    Registrato dal
    Jul 2005
    residenza
    Roma
    Messaggi
    36,480
    Molto probabilmente (ma questo lo puoi verificare solamente tu), la sub viene eseguita una prima volta (e Add diventa 10) e poi termina per essere richiamata una seconda volta cosi' che Add parte da 0 e poi nel ciclo va a 1 e 2 ...
    No MP tecnici (non rispondo nemmeno!), usa il forum.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.