ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Understanding this code snippett (https://www.excelbanter.com/excel-programming/326924-understanding-code-snippett.html)

Stuart[_21_]

Understanding this code snippett
 
I have 'found' these lines:

If Len(Dir(Application.Path & "\" & "abc.exe")) = 0 _
Or Len(Dir(Application.Path & "\" & "xyz.dll")) _
= 0 Then
MsgBox " very long message "
Exit Sub
End If
Load UserForm1
UserForm1.Show
End Sub

What exactly is the If statement trying to determine,
please?

Regards.



Ed

Understanding this code snippett
 
Len(string) give you the length (number of characters) in the given text
string. Since your string is a path to a file (actually the return of the
Dir function checking that path), if the path is not good, Len returns 0.
In effect, it seems to be checking whether you have a valid file path.

You can get more (and better!) info by going into the VBE Help and looking
at both Dir and Len.

Ed

"Stuart" wrote in message
...
I have 'found' these lines:

If Len(Dir(Application.Path & "\" & "abc.exe")) = 0 _
Or Len(Dir(Application.Path & "\" & "xyz.dll")) _
= 0 Then
MsgBox " very long message "
Exit Sub
End If
Load UserForm1
UserForm1.Show
End Sub

What exactly is the If statement trying to determine,
please?

Regards.





Tom Ogilvy

Understanding this code snippett
 
if abc.exe or xyz.dll are missing from the application.path directory.

--
Regards,
Tom Ogilvy

"Stuart" wrote in message
...
I have 'found' these lines:

If Len(Dir(Application.Path & "\" & "abc.exe")) = 0 _
Or Len(Dir(Application.Path & "\" & "xyz.dll")) _
= 0 Then
MsgBox " very long message "
Exit Sub
End If
Load UserForm1
UserForm1.Show
End Sub

What exactly is the If statement trying to determine,
please?

Regards.





Stuart[_21_]

Understanding this code snippett
 
Thanks to you both.......looking for the file was my guess.
I assume that Application.Path MUST exist and be valid
since it must represent the host application (ie Excel or,
say Office) under which the sub is running.

Regards.

"Tom Ogilvy" wrote in message
...
if abc.exe or xyz.dll are missing from the application.path directory.

--
Regards,
Tom Ogilvy

"Stuart" wrote in message
...
I have 'found' these lines:

If Len(Dir(Application.Path & "\" & "abc.exe")) = 0 _
Or Len(Dir(Application.Path & "\" & "xyz.dll")) _
= 0 Then
MsgBox " very long message "
Exit Sub
End If
Load UserForm1
UserForm1.Show
End Sub

What exactly is the If statement trying to determine,
please?

Regards.







No Name

Understanding this code snippett
 
Stuart,

Actually is stopping the execution of the code if either of the two files
"abc.exe" or "xyz.dll" are not present in the application directory path.

Brian

"Stuart" wrote in message
...
Thanks to you both.......looking for the file was my guess.
I assume that Application.Path MUST exist and be valid
since it must represent the host application (ie Excel or,
say Office) under which the sub is running.

Regards.

"Tom Ogilvy" wrote in message
...
if abc.exe or xyz.dll are missing from the application.path directory.

--
Regards,
Tom Ogilvy

"Stuart" wrote in message
...
I have 'found' these lines:

If Len(Dir(Application.Path & "\" & "abc.exe")) = 0 _
Or Len(Dir(Application.Path & "\" & "xyz.dll")) _
= 0 Then
MsgBox " very long message "
Exit Sub
End If
Load UserForm1
UserForm1.Show
End Sub

What exactly is the If statement trying to determine,
please?

Regards.









Tom Ogilvy

Understanding this code snippett
 
As long as we are splitting hairs,
Actually, it puts up a "long message" and then it is exiting the subroutine
that contains that code if either of the files are not existent. This
prevents the userform from being shown. However, if the code is being
called from another subroutine or function, the calling code continues to
execute.

--
Regards,
Tom Ogilvy

wrote in message
...
Stuart,

Actually is stopping the execution of the code if either of the two files
"abc.exe" or "xyz.dll" are not present in the application directory path.

Brian

"Stuart" wrote in message
...
Thanks to you both.......looking for the file was my guess.
I assume that Application.Path MUST exist and be valid
since it must represent the host application (ie Excel or,
say Office) under which the sub is running.

Regards.

"Tom Ogilvy" wrote in message
...
if abc.exe or xyz.dll are missing from the application.path directory.

--
Regards,
Tom Ogilvy

"Stuart" wrote in message
...
I have 'found' these lines:

If Len(Dir(Application.Path & "\" & "abc.exe")) = 0 _
Or Len(Dir(Application.Path & "\" & "xyz.dll")) _
= 0 Then
MsgBox " very long message "
Exit Sub
End If
Load UserForm1
UserForm1.Show
End Sub

What exactly is the If statement trying to determine,
please?

Regards.












All times are GMT +1. The time now is 03:10 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com