Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Incrementing counter on variable value changes

Status
Not open for further replies.

des0906

IS-IT--Management
Jul 30, 2001
69
US
Greetings all.

I have been looking at this code for a bit and I am uncertain of where I have gone wrong. The message box reflects the folder name changes accurately but I never see the counter go beyond 1. This is the only area of the function where the counter value changes. Go figure.

This is part of a function that scans the files in a specified directory and inserts the file names, folder path and other information into a table. I am attempting to create a 'folder group id' for each folder.

If (Trim(TheFolder) = Trim(TheCurrentFolder) = False) Then
TheCurrentFolder = TheFolder
theFolderCount = theFolderCount + 1
If MsgBox("(" & theFolderCount & ",'" & TheCurrentFolder & "')", vbYesNo + vbExclamation,
"Keep Going?") = vbNo Then
End
End If
End If
 
Well, in this snippet, the counter would change to one, if it isn't incremented before. What more are we supposed to read or guess out of what you've posted? One hunch though, depending on how you're invoking this, could declaring theFolderCount with the Static keyword be it?

Roy-Vidar
 
How are ya des0906 . . . . .

You may need to put [blue]theFolderCount[/blue] in the Declarations section of the module to [blue]keep it in scope![/blue]

Calvin.gif
See Ya! . . . . . .
 
Just a naive question, why using this:
If (Trim(TheFolder) = Trim(TheCurrentFolder) = False) Then
Instead of this ?
If Trim(TheFolder) <> Trim(TheCurrentFolder) Then

What is supposed to do the End instruction for you ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
PHV is right! . . . . .
Code:
[blue]If (Trim(TheFolder) = Trim(TheCurrentFolder) = False) Then
[purple]Is Equavilent To:[/purple]
If (A = B = C) Then[/blue]

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top