I'm everywhere and nowhere, I'm inside your computer and inside your mind. You can't escape me for I am vision.
Posts
117
for the buttons on form load have it generate 6 numbers assign 1 number to each of the three buttons left and top commands. this will randomly place the buttons. just make sure that it generates a number within the area of the screen.
1) With One button on your form, Everytime the form loads, the
form appears in a different spot on the screen, but the button
always stays in the same spot on your screen.
-And by the way, if a .txt file exists per spec of question 2, then
its destination by def is the c:\, so the answer is:
[/code]
Private Sub Command1_Click()
DoIExist = Dir("c:\*.txt", vbNormal)
If DoIExist <> "" Then
MsgBox "c:\"
Else
MsgBox "Does Not Exist"
End If
End Sub
[/code]
-Lou
However, I'm stingy today, so I won't load the code.
But, I'll give you some suggestions and hints.
There are many different ways to accomplish what you ask.
The most sophisticated involve useing api functions, which for
dir/file searches is in my opinion, a little bit of an overkill.
However, it certainly crunches the num of code lines down.
You could go the way of using the Microsoft Scripting Runtime
Reference and its various functions, which is extremely
versatile and powerful. However, I've seen it be extremely
taxing on my systems when I've done massive dir/file operations.
For File Repository Maintenance involving thousands of large files and directories, it simplifies file monitering, and automation of renaming, moveing, and databasing of file specs. But for you,
again, this could be overkill.
Now, there is the simple Dir command. This is the one that I would
recommend, especially for this exercise, since it seems you haven't gotten the full usage out of it yet. So, How to do it?
For a Brute force method, consider the following:
Two Textboxes, one to store found dir's, and one to store
*.txt files discovered in those directories.
One command button, to start it up.
Two functions.
One to return all directories resident in a passed path, placeing the dir's into one of the boxes.
Another to perform a *.txt search on a passed path, placeing
those files into another of the boxes.
Now, how to Loop?
First, Clear the boxes. Then Pass "c:\" to both functions.
Once thats done,
do a while on the dir listcount <> 0, and loop thru each entry in the dir list box, last to first, passing them to each function. After a path has been passed to both, remove it, so you won't reprocess it again. Go thru the whole text box this way, and keep wending
until the textbox listcount is zero.
Now, Since you only want the "First" .txt file, throw in a check on your txt listbox, and when the count > 1, STOP!.
1) With One button on your form, Everytime the form loads, the
form appears in a different spot on the screen, but the button
always stays in the same spot on your screen.
I modified your request a bit. When the form loads, drag it around. The button will stay in the same place on the screen. This was very easy to do. The form is attached.