Results 1 to 16 of 16

Thread: [RESOLVED] Class to Class visibility

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2025
    Posts
    182

    Resolved [RESOLVED] Class to Class visibility

    I have several classes which the compiler does not see it seems and does not compile them. These other, non-compiled, classes would generate errors as they are ported VBA code which has yet to be converted to VB.

    The following classes are in my Solution Explorer but are not compiling. Of course my Form1 class compiles and runs, but not the ones below. Now I don't have any instanciated yet but the compiler should still compile them and provide a huge amount of errors from the non-converted files.

    ClsBrowser
    ClsSplashScreen
    ClsEPIQ
    ClsErroLog
    ClsWinCtrls

    They are all Public Classes, so not sure why the compiler does not see them, nor compile them.
    Public Class ClsBrowser

    Any Suggestions

  2. #2
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,745

    Re: Class to Class visibility

    I have issues with non complied classed and I just close the Visual Studio and re-open it and I see them.
    Granted these apps are web based but...
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2025
    Posts
    182

    Re: Class to Class visibility

    Quote Originally Posted by sapator View Post
    I have issues with non complied classed and I just close the Visual Studio and re-open it and I see them.
    Granted these apps are web based but...
    Thanks. I have closed VS multiple times, but the classes still are not seen by the compiler and compiled. This seems weird to me as when I was programming a bit here and there with C++, many decades ago, any class added to the project would get compiled. So I'm scratching my head as to why the compiler does not see these other classes.

  4. #4
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,852

    Re: Class to Class visibility

    Quote Originally Posted by FunkMonkey View Post
    I have several classes which the compiler does not see it seems and does not compile them. These other, non-compiled, classes would generate errors as they are ported VBA code which has yet to be converted to VB.

    The following classes are in my Solution Explorer but are not compiling. Of course my Form1 class compiles and runs, but not the ones below. Now I don't have any instanciated yet but the compiler should still compile them and provide a huge amount of errors from the non-converted files.

    ClsBrowser
    ClsSplashScreen
    ClsEPIQ
    ClsErroLog
    ClsWinCtrls

    They are all Public Classes, so not sure why the compiler does not see them, nor compile them.
    Public Class ClsBrowser

    Any Suggestions
    Are those classes part of a project, or are they directly under the Solution? They need to be part of the project to be compiled.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Mar 2025
    Posts
    182

    Re: Class to Class visibility

    Quote Originally Posted by PlausiblyDamp View Post
    Are those classes part of a project, or are they directly under the Solution? They need to be part of the project to be compiled.
    Yes they are all in the Solution Items list. I'd show a picture of the solution, but the file does not get loaded but that is a different issue.

    Thats what is strange to me is that they are not seen by the compiler.

  6. #6
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,857

    Re: Class to Class visibility

    Quote Originally Posted by PlausiblyDamp View Post
    Are those classes part of a project, or are they directly under the Solution? They need to be part of the project to be compiled.
    @FunkMonkey - read it again please.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Mar 2025
    Posts
    182

    Re: Class to Class visibility

    Quote Originally Posted by dbasnett View Post
    @FunkMonkey - read it again please.
    The only place they will go is in Solution. I can't drag them to the project EPIQ Interface. So how do I get them there if that is where they go? The forms I generated are there but none of the *.vb filew will go there.

    EDIT. OK, you have to drop them directly on the project and not drag and drop. Thanks for the input.

  8. #8
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    39,796

    Re: Class to Class visibility

    Pictures added to quick reply tend not to work. While I have not tried it, my understanding is that you have to add pictures with Go Advanced.
    My usual boring signature: Nothing

  9. #9
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    39,796

    Re: Class to Class visibility

    Dragging and dropping files into the project may not be the way to go anyways. That might add them to the folder without adding them to the project. Whenever I add an existing class, I right click on the project (or go to the Project Properties menu) and choose Add Existing Item. This will work even for things that the compiler doesn't recognize, but if it's a code file with a .vb extension then it will certainly be added to the project and compiled.
    My usual boring signature: Nothing

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Mar 2025
    Posts
    182

    Re: Class to Class visibility

    Quote Originally Posted by Shaggy Hiker View Post
    Pictures added to quick reply tend not to work. While I have not tried it, my understanding is that you have to add pictures with Go Advanced.
    Thanks Shaggy. I was able to select the file, but nothing ever came of it. It did not load my *.jpg. Cant go beyond loading it up to the system to display.

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Mar 2025
    Posts
    182

    Re: Class to Class visibility

    Quote Originally Posted by Shaggy Hiker View Post
    Dragging and dropping files into the project may not be the way to go anyways. That might add them to the folder without adding them to the project. Whenever I add an existing class, I right click on the project (or go to the Project Properties menu) and choose Add Existing Item. This will work even for things that the compiler doesn't recognize, but if it's a code file with a .vb extension then it will certainly be added to the project and compiled.
    Thaks Shaggy. Never tried it that way. So used to drag and drop.

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Mar 2025
    Posts
    182

    Re: Class to Class visibility

    Quote Originally Posted by FunkMonkey View Post
    Thaks Shaggy. Never tried it that way. So used to drag and drop.
    Staying with the compiler cant see class.... At this point the classes are seen, and erroring as they should, but.... The Defines module seems to not be sharing API functions.
    Code:
        Public Declare Function FindWindowA Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
        Public Declare Function DeleteMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
        Public Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, ByVal bRevert As Long) As Long
        Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
        Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
        Public Declare Function DrawMenuBar Lib "user32" (ByVal hWnd As Long) As Long
        Public Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
        Public Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
        Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
        Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As VariantType) As Long
        Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As VariantType) As Long
    
        Public Declare Function GetForegroundWindow Lib "user32" () As Long
        Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
        Public Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long
        Public Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
        Public Declare Function SetEnvironmentVariable Lib "kernel32" Alias "SetEnvironmentVariableA" (ByVal lpName As String, ByVal lpValue As String) As Long
        Public Declare Function CloseClipboard Lib "user32" () As Long
        Public Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, ByVal lpProcName As String) As Long
    
        Private Declare Function SetTimer Lib "user32" (ByVal hWnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
        Private Declare Function KillTimer Lib "user32" (ByVal hWnd As Long, ByVal nIDEvent As Long) As Long
    
    #If VBA7 Then
        Public Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As LongPtr) 'For 64-Bit versions of Excel
        'Private Declare PtrSafe Function DispCallFunc Lib "OleAut32.dll" (ByVal pvInstance As LongPtr, ByVal FuncAddr As LongPtr, ByVal CallConvention As Integer, ByVal rtnType As VbVarType, ByVal FuncArgsCnt As Long, ByRef FuncArgTypes As Any, ByRef FuncArgVarAddresses As Any, ByRef FuncResult As Any) As Long
        Private Declare PtrSafe Function IsIconic Lib "user32.dll" (ByVal hWnd As Long) As Long
    #Else
        Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) 'For 32-Bit versions of Excel
        'Private Declare Function DispCallFunc Lib "OleAut32.dll" (ByVal pvInstance As Long, ByVal FuncAddr As Long, ByVal CallConvention As Integer, ByVal rtnType As VariantType, ByVal FuncArgsCnt As Long, ByRef FuncArgTypes As Any, ByRef FuncArgVarAddresses As Any, ByRef FuncResult As Any) As Long
        Private Declare Function IsIconic Lib "user32.dll" (ByVal hWnd As Long) As Long
    #End If
    I'm sure its probably as easy as adding the correct line at the top of the Define file, but what would that line be? I'm used to applying either *.h or the module worked in VBA?

    Can you enlighten me on this API issue not being seen in the compile?

  13. #13
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,852

    Re: Class to Class visibility

    Is that all that is in the file? If so those declares will need to be inside either a module or a class.

  14. #14

    Thread Starter
    Addicted Member
    Join Date
    Mar 2025
    Posts
    182

    Re: Class to Class visibility

    Quote Originally Posted by PlausiblyDamp View Post
    Is that all that is in the file? If so those declares will need to be inside either a module or a class.
    No, there are a bunch of defines in there. They all seem to work, as they do not produce errors on the Constant defines. The others I know what needs to be done to fix the enum issues.

    EDIT: Got it. Looks like it could be user error. Still don't understand the fix, but it worked.
    Last edited by FunkMonkey; Mar 18th, 2025 at 01:44 PM.

  15. #15
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,852

    Re: [RESOLVED] Class to Class visibility

    How are you trying to reference those declared functions in your other code? Are those declares part of a class or a module?

    When you try and use them are you getting any specific errors?

  16. #16
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,066

    Re: Class to Class visibility

    Quote Originally Posted by FunkMonkey View Post
    Staying with the compiler cant see class.... At this point the classes are seen, and erroring as they should, but.... The Defines module seems to not be sharing API functions.
    Code:
        Public Declare Function FindWindowA Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
        Public Declare Function DeleteMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
        Public Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, ByVal bRevert As Long) As Long
        Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
        Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
        Public Declare Function DrawMenuBar Lib "user32" (ByVal hWnd As Long) As Long
        Public Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
        Public Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
        Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
        Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As VariantType) As Long
        Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As VariantType) As Long
    
        Public Declare Function GetForegroundWindow Lib "user32" () As Long
        Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
        Public Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long
        Public Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
        Public Declare Function SetEnvironmentVariable Lib "kernel32" Alias "SetEnvironmentVariableA" (ByVal lpName As String, ByVal lpValue As String) As Long
        Public Declare Function CloseClipboard Lib "user32" () As Long
        Public Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, ByVal lpProcName As String) As Long
    
        Private Declare Function SetTimer Lib "user32" (ByVal hWnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
        Private Declare Function KillTimer Lib "user32" (ByVal hWnd As Long, ByVal nIDEvent As Long) As Long
    
    #If VBA7 Then
        Public Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As LongPtr) 'For 64-Bit versions of Excel
        'Private Declare PtrSafe Function DispCallFunc Lib "OleAut32.dll" (ByVal pvInstance As LongPtr, ByVal FuncAddr As LongPtr, ByVal CallConvention As Integer, ByVal rtnType As VbVarType, ByVal FuncArgsCnt As Long, ByRef FuncArgTypes As Any, ByRef FuncArgVarAddresses As Any, ByRef FuncResult As Any) As Long
        Private Declare PtrSafe Function IsIconic Lib "user32.dll" (ByVal hWnd As Long) As Long
    #Else
        Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) 'For 32-Bit versions of Excel
        'Private Declare Function DispCallFunc Lib "OleAut32.dll" (ByVal pvInstance As Long, ByVal FuncAddr As Long, ByVal CallConvention As Integer, ByVal rtnType As VariantType, ByVal FuncArgsCnt As Long, ByRef FuncArgTypes As Any, ByRef FuncArgVarAddresses As Any, ByRef FuncResult As Any) As Long
        Private Declare Function IsIconic Lib "user32.dll" (ByVal hWnd As Long) As Long
    #End If
    I'm sure its probably as easy as adding the correct line at the top of the Define file, but what would that line be? I'm used to applying either *.h or the module worked in VBA?

    Can you enlighten me on this API issue not being seen in the compile?
    One thing that I will point out that often trips up inexperienced VB.NET developers is that any declaration there with a parameter or return type of Long is likely to not work. Windows API functions use almost exclusively 32-bit numbers. in VB6 and, presumably, VBA, the Long data type is 32-bit. In VB.NET, the Long data type is 64-bit and the Integer data type is 32-bit. If you have an API declaration that was written for VB6 or VBA, you need to change any Long parameter or return type to Integer. I see at least one LongPtr in there too, so I'm guessing that that would need to become IntPtr as well. Also, while Integer will work, it's generally more appropriate to use IntPtr for window handles and the like.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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