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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

2 easy ones... 2

Status
Not open for further replies.

Eek

Technical User
Feb 4, 2001
34
CA
I've got 2 easy ones for you:

1-I'm trying to change the attribute of a file with this statement:
setattr("c:\test.dll",vbnormal)=1
but it doesn't work...I want to restrore all the attribute of this file to normal...such as the DOS command :
attrib -r -a -s -h c:\test.dll

2-When the user navigates through my program some forms are showed & hidden ....how do I make sure all the forms get unloaded when the user clicks on the " X " to exit my program ?

Any help would be greatly appreciated
 
#1 - I have not used the setattr command but you could shell out to DOS and use the ATTRIB command there.

#2 - dim f as form
for each f in forms
unload f
'or if f.name <> me.name then unload f ' if you don't want to unload current form.
next
 
thanks sodakotahusker , I'll shell a DOS command to solve #1.....but for #2 I know how to create the unload loop but how to trigger it when the user click on the &quot;X&quot; to close my application is the problem. (I can't use the &quot;loastfocus&quot; because it will trigger the loop when the user changes form).

 
It is inefficient to shell out to DOS simply to set a file attribute and I would not recommend doing this (even though it will work). You idea of using Setattr was the correct way to go, but you were not using it correctly. You do not need to set the value = 1 as you were doing. you simple call the function. Instead use it like this . . .


SetAttr &quot;C:\Text.txt&quot;, vbReadOnly + vbArchive


The file attribute is made of a logical bitmask and you can combine attribute by ORing then together (or in VB, simply add them up). This is a much better approach then shelling out to DOS to do this.

Also, to close all of your forms in your app when the app shuts down, simply close all forms that exist in the global forms collection.


















- Jeff Marler B-)
 
Thanks Jeff !

Can you elaborate on : &quot;Also, to close all of your forms in your app when the app shuts down, simply close all forms that exist in the global forms collection.&quot;

I'm a beginner with VB, if it's not too long would you mind giving me more info on how to do that.


 
dim objForm as Form

for each objForm in forms
unload objForm
set objForm = nothing
next objForm - Jeff Marler B-)
 
you trigger it on the queryunload event for the form. That fires whenever the form is being unloaded. If the unloadmode variable is equal to 0, then the x was clicked in the form. If it is 1, a normal unload was issued. I believe it equals 2 if a boot of the computer has been requested.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top