|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Make a BackupOption Explicit Private Const FILE_ATTRIBUTE_DIRECTORY As Long = &H10 I am stuck as I cannot see why this line of code does not work:- 1. When they are equal 2. When they are not equal I am getting the same result nothing within the if statement is being called whether they are equal or not. 'if the object is not a folder.. If (WFDSource.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY) <> FILE_ATTRIBUTE_DIRECTORY Then other code end if When the WFDSource.dwFileAttributes is not a folder its value = 17 and when it is a folder its value = 16 FILE_ATTRIBUTE_DIRECTORY value = 16 is it the And FILE_ATTRIBUTE_DIRECTORY that is causing the problem? Can you help?
Show quote
Hide quote
"LondonLad" <London***@discussions.microsoft.com> wrote in message Okay, I'll be the one to ask. Do you understand the concept bit operations? news:7D3A36E3-8722-494B-91D2-6E1A725EEB5D@microsoft.com... :I am using Randy Birch's CopyFileEx: Create a File Backup App : : Option Explicit : Private Const FILE_ATTRIBUTE_DIRECTORY As Long = &H10 : : I am stuck as I cannot see why this line of code does not work:- : : 1. When they are equal : 2. When they are not equal : : I am getting the same result nothing within the if statement is being called : whether they are equal or not. : : 'if the object is not a folder.. : If (WFDSource.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY) <> : FILE_ATTRIBUTE_DIRECTORY Then : : other code : : end if : : When the WFDSource.dwFileAttributes is not a folder its value = 17 and when : it is a folder its value = 16 : : FILE_ATTRIBUTE_DIRECTORY value = 16 is it the : And FILE_ATTRIBUTE_DIRECTORY that is causing the problem? : : Can you help? If not, the answer won't make any sense to you. Google "Logical and Bitwise operators". The answer should then be apparent.
Show quote
Hide quote
"LondonLad" <London***@discussions.microsoft.com> wrote in message That code is fine.news:7D3A36E3-8722-494B-91D2-6E1A725EEB5D@microsoft.com... > I am using Randy Birch's CopyFileEx: Create a File Backup App > > Option Explicit > Private Const FILE_ATTRIBUTE_DIRECTORY As Long = &H10 > > I am stuck as I cannot see why this line of code does not work:- > > 1. When they are equal > 2. When they are not equal > > I am getting the same result nothing within the if statement is being > called > whether they are equal or not. > > 'if the object is not a folder.. > If (WFDSource.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY) <> > FILE_ATTRIBUTE_DIRECTORY Then > > other code > > end if > Here's where you're mistaken. If dwFileAttributes has a value of 17, then it > When the WFDSource.dwFileAttributes is not a folder its value = 17 and > when > it is a folder its value = 16 IS a directory that also has the read-only attribute. The constant for this attribute is: Public Const FILE_ATTRIBUTE_READONLY = &H1 In decimal form, the values are 16 (for directory) and 1 (for read-only). Added together, it means that BOTH attributes are present. Try this in the Immediate window: ? 17 and 16 This will print 16 into the immediate window. For a little bit closer representation of your code above, try this in the immediate window: ? (17 and 16) <> 16 Note that it prints False. The problem doesn't appear to be with the code. Verify what you have for the cFileName member of the WIN32_FIND_DATA structure. You'll probably find it really is a directory name. -- Mike Hi Mike
Yes I will be the first to admit that i do not have any knowledge on bit operations but so far this has not stopped me from getting useful code to work to my requirements. I have read the article that Kevin Provance suggested at that has not helped me to understand the problem I have. As you said I had tried the prints to the intermediate window and I get this result ? (17 and 16) <> 16 Result False ? (16 and 16) <> 16 Result False is this the correct answer? it seem from what you said it is. OK You said to look at cFileName which I have and this is a Folder Name and one of the many that should be checked for Date Created. Can you help further please? Show quoteHide quote "MikeD" wrote: > > > "LondonLad" <London***@discussions.microsoft.com> wrote in message > news:7D3A36E3-8722-494B-91D2-6E1A725EEB5D@microsoft.com... > > I am using Randy Birch's CopyFileEx: Create a File Backup App > > > > Option Explicit > > Private Const FILE_ATTRIBUTE_DIRECTORY As Long = &H10 > > > > I am stuck as I cannot see why this line of code does not work:- > > > > 1. When they are equal > > 2. When they are not equal > > > > I am getting the same result nothing within the if statement is being > > called > > whether they are equal or not. > > > > 'if the object is not a folder.. > > If (WFDSource.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY) <> > > FILE_ATTRIBUTE_DIRECTORY Then > > > > other code > > > > end if > > That code is fine. > > > > > When the WFDSource.dwFileAttributes is not a folder its value = 17 and > > when > > it is a folder its value = 16 > > Here's where you're mistaken. If dwFileAttributes has a value of 17, then it > IS a directory that also has the read-only attribute. The constant for this > attribute is: > > Public Const FILE_ATTRIBUTE_READONLY = &H1 > > In decimal form, the values are 16 (for directory) and 1 (for read-only). > Added together, it means that BOTH attributes are present. Try this in the > Immediate window: > > ? 17 and 16 > > This will print 16 into the immediate window. For a little bit closer > representation of your code above, try this in the immediate window: > > ? (17 and 16) <> 16 > > Note that it prints False. > > The problem doesn't appear to be with the code. Verify what you have for > the cFileName member of the WIN32_FIND_DATA structure. You'll probably find > it really is a directory name. > > -- > Mike > > > . > "LondonLad" <London***@discussions.microsoft.com> skrev i meddelandet 17 and 16 equals 16, so 16 not equal to 16 is False because they *are* news:0AD8E3F1-3320-45E1-9142-1CFDCF615D9B@microsoft.com... > Hi Mike > Yes I will be the first to admit that i do not have any knowledge on bit > operations but so far this has not stopped me from getting useful code to > work to my requirements. I have read the article that Kevin Provance > suggested at that has not helped me to understand the problem I have. > As you said I had tried the prints to the intermediate window and I get > this > result > > ? (17 and 16) <> 16 Result False equal. > ? (16 and 16) <> 16 Result False Same thing here 16 <> 16 is False.If the thread starts bottomposting, plz continue that, to make it readable. /Henning Show quoteHide quote > is this the correct answer? it seem from what you said it is. OK > > You said to look at cFileName which I have and this is a Folder Name and > one > of the many that should be checked for Date Created. > > Can you help further please? > > > "MikeD" wrote: > >> >> >> "LondonLad" <London***@discussions.microsoft.com> wrote in message >> news:7D3A36E3-8722-494B-91D2-6E1A725EEB5D@microsoft.com... >> > I am using Randy Birch's CopyFileEx: Create a File Backup App >> > >> > Option Explicit >> > Private Const FILE_ATTRIBUTE_DIRECTORY As Long = &H10 >> > >> > I am stuck as I cannot see why this line of code does not work:- >> > >> > 1. When they are equal >> > 2. When they are not equal >> > >> > I am getting the same result nothing within the if statement is being >> > called >> > whether they are equal or not. >> > >> > 'if the object is not a folder.. >> > If (WFDSource.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY) <> >> > FILE_ATTRIBUTE_DIRECTORY Then >> > >> > other code >> > >> > end if >> >> That code is fine. >> >> > >> > When the WFDSource.dwFileAttributes is not a folder its value = 17 and >> > when >> > it is a folder its value = 16 >> >> Here's where you're mistaken. If dwFileAttributes has a value of 17, then >> it >> IS a directory that also has the read-only attribute. The constant for >> this >> attribute is: >> >> Public Const FILE_ATTRIBUTE_READONLY = &H1 >> >> In decimal form, the values are 16 (for directory) and 1 (for read-only). >> Added together, it means that BOTH attributes are present. Try this in >> the >> Immediate window: >> >> ? 17 and 16 >> >> This will print 16 into the immediate window. For a little bit closer >> representation of your code above, try this in the immediate window: >> >> ? (17 and 16) <> 16 >> >> Note that it prints False. >> >> The problem doesn't appear to be with the code. Verify what you have for >> the cFileName member of the WIN32_FIND_DATA structure. You'll probably >> find >> it really is a directory name. >> >> -- >> Mike >> >> >> . >> | Yes I will be the first to admit that i do not have any knowledge on bit Since it's a bit flag you're comparing bit values. It's| operations but so far this has not stopped me from getting useful code to | work to my requirements. I have read the article that Kevin Provance | suggested at that has not helped me to understand the problem I have. | As you said I had tried the prints to the intermediate window and I get this | result | | ? (17 and 16) <> 16 Result False | ? (16 and 16) <> 16 Result False | is this the correct answer? it seem from what you said it is. OK | misleading because "And" doesn't make sense until you know that. The values in binary are: 16: 00010000 17: 00010001 So 17 And 16 = 16 because that is the sum of the shared bits. By doing x And 16 you can check whether the 16 bit is set. It doesn't matter which other bits are or are not set. "And" is just a simple masking device. (If that doesn't make sense you might want to look up how decimal/hex/binary values express numbers and how that relates to bits. Hi Mayayana
Thank for your very clear explanation what would be the bit answer that is equal and allow code within the if statement to function. 'if the object is not a folder If (WFDSource.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY) <> FILE_ATTRIBUTE_DIRECTORY Then other code End if I thought that the author was making sure that it was a folder its seems to me that when it is a folder it still does not become equal and therefore does not satisfy the question. I would appreciate further help if you can. Show quoteHide quote "Mayayana" wrote: > | Yes I will be the first to admit that i do not have any knowledge on bit > | operations but so far this has not stopped me from getting useful code to > | work to my requirements. I have read the article that Kevin Provance > | suggested at that has not helped me to understand the problem I have. > | As you said I had tried the prints to the intermediate window and I get > this > | result > | > | ? (17 and 16) <> 16 Result False > | ? (16 and 16) <> 16 Result False > | is this the correct answer? it seem from what you said it is. OK > | > > Since it's a bit flag you're comparing bit values. It's > misleading because "And" doesn't make sense > until you know that. The values in binary are: > > 16: 00010000 > 17: 00010001 > > So 17 And 16 = 16 because that is the sum of the shared > bits. By doing x And 16 you can check whether the 16 bit is > set. It doesn't matter which other bits are or are not set. "And" > is just a simple masking device. (If that doesn't make sense > you might want to look up how decimal/hex/binary values > express numbers and how that relates to bits. > > > > . > OBS! 'if the object is *not* a folder
/Henning Show quoteHide quote "LondonLad" <London***@discussions.microsoft.com> skrev i meddelandet news:68992D5B-C45F-47AF-9497-C7BE19587CB1@microsoft.com... > Hi Mayayana > Thank for your very clear explanation what would be the bit answer that is > equal and allow code within the if statement to function. > > 'if the object is not a folder > If (WFDSource.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY) <> > FILE_ATTRIBUTE_DIRECTORY Then > > other code > > End if > > I thought that the author was making sure that it was a folder its seems > to > me that when it is a folder it still does not become equal and therefore > does > not satisfy the question. > > I would appreciate further help if you can. > > "Mayayana" wrote: > >> | Yes I will be the first to admit that i do not have any knowledge on >> bit >> | operations but so far this has not stopped me from getting useful code >> to >> | work to my requirements. I have read the article that Kevin Provance >> | suggested at that has not helped me to understand the problem I have. >> | As you said I had tried the prints to the intermediate window and I get >> this >> | result >> | >> | ? (17 and 16) <> 16 Result False >> | ? (16 and 16) <> 16 Result False >> | is this the correct answer? it seem from what you said it is. OK >> | >> >> Since it's a bit flag you're comparing bit values. It's >> misleading because "And" doesn't make sense >> until you know that. The values in binary are: >> >> 16: 00010000 >> 17: 00010001 >> >> So 17 And 16 = 16 because that is the sum of the shared >> bits. By doing x And 16 you can check whether the 16 bit is >> set. It doesn't matter which other bits are or are not set. "And" >> is just a simple masking device. (If that doesn't make sense >> you might want to look up how decimal/hex/binary values >> express numbers and how that relates to bits. >> >> >> >> . >> A little too fast, again...
If you want If (WFD.....) to satisfy when it is a Dir, then change <> to =. /Henning Show quoteHide quote "Henning" <computer_h***@coldmail.com> skrev i meddelandet news:i3k91o$s7a$1@news.eternal-september.org... > OBS! 'if the object is *not* a folder > > /Henning > > "LondonLad" <London***@discussions.microsoft.com> skrev i meddelandet > news:68992D5B-C45F-47AF-9497-C7BE19587CB1@microsoft.com... >> Hi Mayayana >> Thank for your very clear explanation what would be the bit answer that >> is >> equal and allow code within the if statement to function. >> >> 'if the object is not a folder >> If (WFDSource.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY) <> >> FILE_ATTRIBUTE_DIRECTORY Then >> >> other code >> >> End if >> >> I thought that the author was making sure that it was a folder its seems >> to >> me that when it is a folder it still does not become equal and therefore >> does >> not satisfy the question. >> >> I would appreciate further help if you can. >> >> "Mayayana" wrote: >> >>> | Yes I will be the first to admit that i do not have any knowledge on >>> bit >>> | operations but so far this has not stopped me from getting useful code >>> to >>> | work to my requirements. I have read the article that Kevin Provance >>> | suggested at that has not helped me to understand the problem I have. >>> | As you said I had tried the prints to the intermediate window and I >>> get >>> this >>> | result >>> | >>> | ? (17 and 16) <> 16 Result False >>> | ? (16 and 16) <> 16 Result False >>> | is this the correct answer? it seem from what you said it is. OK >>> | >>> >>> Since it's a bit flag you're comparing bit values. It's >>> misleading because "And" doesn't make sense >>> until you know that. The values in binary are: >>> >>> 16: 00010000 >>> 17: 00010001 >>> >>> So 17 And 16 = 16 because that is the sum of the shared >>> bits. By doing x And 16 you can check whether the 16 bit is >>> set. It doesn't matter which other bits are or are not set. "And" >>> is just a simple masking device. (If that doesn't make sense >>> you might want to look up how decimal/hex/binary values >>> express numbers and how that relates to bits. >>> >>> >>> >>> . >>> > > "LondonLad" <London***@discussions.microsoft.com> wrote That code tests to see if the attributes say its NOT a folder.> 'if the object is not a folder > If (WFDSource.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY) <> > FILE_ATTRIBUTE_DIRECTORY Then > > I thought that the author was making sure that it was a folder If (MyValue And SOMETEST) = SOMETEST Then ' The tested attribute is present If (MyValue And SOMETEST) <> SOMETEST Then ' The tested attribute is not present LFS "LondonLad" <London***@discussions.microsoft.com> wrote in message Why not use TaskZip? It's written in VB6 and available in source code news:7D3A36E3-8722-494B-91D2-6E1A725EEB5D@microsoft.com... >I am using Randy Birch's CopyFileEx: Create a File Backup App format. Here is a link to the source code: http://web.archive.org/web/20000821154048/http://jupiter.drw.net/matpie/Downloads/TZipSource.zip It has backup options like days of the week, monthly, etc., and interface like Task Scheduler. It ZIPs or just copy over uncompressed. I prefer the copy over option. It's using zip.exe command line option, which I don't know if it has 2GB limit. It does check for the exit code though. It's a decent software nevertheless.
ini in app.pth works for xp, best practice for Vista/W7?
Get Selected Path From Explorer How to save a picturebox's image to a .PNG file? (VB6) Unicode API System Timer Callback? Old VB Project doesn't work with New Office or Windows 7 RegClean Revisited App Hang Are PDB files used by VB6 Reconnection issue between Winsock Server(VB6) and TCP Client (VB.NET) |
|||||||||||||||||||||||