-
Question about position of Declares
I have some code that will open the FileOpen dialog and display it to the
user. Obviously, part of the code goes in the forms declaration section
and some goes after the command button. I was told to place the following
code in the declarations section but when I do I get an error saying that
it's a no no (something about constants, public declarations, etc aren't
allowed here). Can anyone give me some advise on what's wrong? Here is the
code I am placing in the forms DECLARATION section:
Public Type OPENFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
lpstrFilter As String
lpstrCustomFilter As String
nMaxCustomFilter As Long
nFilterIndex As Long
lpstrFile As String
nMaxFile As Long
lpstrFileTitle As String
nMaxFileTitle As Long
lpstrInitialDir As String
lpstrTitle As String
flags As Long
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type
Public Const OFN_FILEMUSTEXIST = &H1000
Public Const OFN_HIDEREADONLY = &H4
Public Const OFN_PATHMUSTEXIST = &H800
Public Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA"
(lpofn _
As OPENFILENAME) As Long
-
Re: Question about position of Declares
Hi Anthony,
You can't have Public declares in a form module -- changing them to be
Private instead should help, but will of course limit access to those API
calls and constants to your form module.
'//mdb
-
Re: Question about position of Declares
Hi Anthony,
You can't have Public declares in a form module -- changing them to be
Private instead should help, but will of course limit access to those API
calls and constants to your form module.
'//mdb
-
Re: Question about position of Declares
Thank you for the info.
Worked like a charm :-)
Anthony
-
Re: Question about position of Declares
Thank you for the info.
Worked like a charm :-)
Anthony
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks