Question about position of Declares


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: Question about position of Declares

  1. #1
    Anthony Guest

    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


  2. #2
    michiel de bruijn Guest

    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




  3. #3
    michiel de bruijn Guest

    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




  4. #4
    anthony Guest

    Re: Question about position of Declares


    Thank you for the info.
    Worked like a charm :-)

    Anthony

  5. #5
    anthony Guest

    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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center