Results 1 to 8 of 8

Thread: Whats wrong with this!!!

  1. #1

    Thread Starter
    PowerPoster Beacon's Avatar
    Join Date
    Jan 2001
    Location
    Pub Floor
    Posts
    3,188

    Unhappy

    I keep getting the error:
    Compile Error
    Constants, fixed lenght strings, blah blah and Declare Statements are not allowed as Public Members of Object Modules!

    How do i fix it?

    Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

    Private Sub Check2_Click()
    Dim retval As Long ' return value
    Dim x As Integer
    x = "F:\R S G\masters\RSG Jobs\job numbers listing.xls"

    ' 1. Run the program:
    retval = ShellExecute(Form1.hwnd, "open", x, "-fast", "C:\MyProg\")
    End Sub

    Private Sub Command1_Click()
    Dim retval As Long ' return value
    Dim x As Integer
    x = "F:\R S G\masters\RSG Jobs\job numbers listing.xls"
    ' 1. Run the program:
    retval = ShellExecute(Form1.hwnd, "open", x, "-fast", "C:\MyProg\")

    Check1.Value = 1
    End Sub

  2. #2
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    put your api's in a .bas module

  3. #3
    Guest
    Yeah, Lethal is correct because you cant make a public declaration in a form.

  4. #4

    Thread Starter
    PowerPoster Beacon's Avatar
    Join Date
    Jan 2001
    Location
    Pub Floor
    Posts
    3,188
    I moved this:
    Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

    to a module but when i run my code i get this error:

    "Compile Error Arguement not optional."
    Then it highlights then ShellExecute line of code in my form! Not the module

    ????????????????????

  5. #5
    Guest
    That is because you left out some parameters while calling th ShellExecute Command. If a cetain parameter is not optional, you must fill it out.

  6. #6
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Public to private

    If one form, change public to private in the general section... best in a BAS (public)
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  7. #7

    Thread Starter
    PowerPoster Beacon's Avatar
    Join Date
    Jan 2001
    Location
    Pub Floor
    Posts
    3,188
    Am i dumb or am i dumb?
    thanks

  8. #8
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    Not dumb, just not aware of the proper use. I bet you probably wont make the same mistake again.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width