-
Mar 18th, 2025, 09:13 AM
#1
Thread Starter
Addicted Member
[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
-
Mar 18th, 2025, 09:23 AM
#2
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...
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Mar 18th, 2025, 09:28 AM
#3
Thread Starter
Addicted Member
Re: Class to Class visibility
 Originally Posted by sapator
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.
-
Mar 18th, 2025, 09:29 AM
#4
Re: Class to Class visibility
 Originally Posted by FunkMonkey
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.
-
Mar 18th, 2025, 09:40 AM
#5
Thread Starter
Addicted Member
Re: Class to Class visibility
 Originally Posted by PlausiblyDamp
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.
-
Mar 18th, 2025, 10:04 AM
#6
Re: Class to Class visibility
 Originally Posted by PlausiblyDamp
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.
-
Mar 18th, 2025, 10:38 AM
#7
Thread Starter
Addicted Member
Re: Class to Class visibility
 Originally Posted by dbasnett
@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.
-
Mar 18th, 2025, 10:44 AM
#8
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
 
-
Mar 18th, 2025, 10:47 AM
#9
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
 
-
Mar 18th, 2025, 11:41 AM
#10
Thread Starter
Addicted Member
Re: Class to Class visibility
 Originally Posted by Shaggy Hiker
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.
-
Mar 18th, 2025, 11:42 AM
#11
Thread Starter
Addicted Member
Re: Class to Class visibility
 Originally Posted by Shaggy Hiker
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.
-
Mar 18th, 2025, 11:51 AM
#12
Thread Starter
Addicted Member
Re: Class to Class visibility
 Originally Posted by FunkMonkey
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?
-
Mar 18th, 2025, 12:42 PM
#13
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.
-
Mar 18th, 2025, 01:00 PM
#14
Thread Starter
Addicted Member
Re: Class to Class visibility
 Originally Posted by PlausiblyDamp
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.
-
Mar 18th, 2025, 01:48 PM
#15
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?
-
Mar 19th, 2025, 12:46 AM
#16
Re: Class to Class visibility
 Originally Posted by FunkMonkey
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.
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
|
Click Here to Expand Forum to Full Width
|