"Compile error: User-defined type not defined"

"Compile error: User-defined type not defined"

Post by Jack » Thu, 23 Feb 2006 06:26:04


The code looks like this: form:
====================
Option Explicit
Private Declare Function SHBrowseForFolder Lib "shell32.dll" Alias
"SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long

Private Type BROWSEINFO
hwndOwner As Long
PidlRoot As Long
PszDisplayName As String
LpszTitle As String
UlFlags As Long
Lpfn As Long
lParam As Long
IImage As Long
End Type
==============================================
and the part of subroutine looks like that:
================================
Dim Info As BROWSEINFO
Dim PID As Long, Path As String, Tmp As String
Dim localpath As String
localpath = txtRecStore.Text
Info.hwndOwner = Me.hwnd
Info.PidlRoot = &H0
Info.LpszTitle = "Select folder to store recordings:"
Info.UlFlags = &H1
PID = SHBrowseForFolder(Info)
^ --------->Info
is highlighted when the error appears
======================================

Sometimes, when creating executable, the compilier complains about that Info
above.
"Compile error: User-defined type not defined"
It usually happens after I execute code (several times) and then try to
compile program to the executable.
However, when I close vbasic and restart it again and try to compile code
there is NOT that error.

Your comments please,
Jack
 
 
 

"Compile error: User-defined type not defined"

Post by Jeff Johns » Thu, 23 Feb 2006 06:51:30


"Welcome to VB."

 
 
 

"Compile error: User-defined type not defined"

Post by Lance Wyn » Thu, 23 Feb 2006 22:43:24

I've had this before, and I've been able to fix it by putting the type
definition physically before the API Declaration in the code. I guess then
the compiler finds the type before it gets to the declaration.

Lance




The code looks like this: form:
====================
Option Explicit
Private Declare Function SHBrowseForFolder Lib "shell32.dll" Alias
"SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long

Private Type BROWSEINFO
hwndOwner As Long
PidlRoot As Long
PszDisplayName As String
LpszTitle As String
UlFlags As Long
Lpfn As Long
lParam As Long
IImage As Long
End Type
==============================================
and the part of subroutine looks like that:
================================
Dim Info As BROWSEINFO
Dim PID As Long, Path As String, Tmp As String
Dim localpath As String
localpath = txtRecStore.Text
Info.hwndOwner = Me.hwnd
Info.PidlRoot = &H0
Info.LpszTitle = "Select folder to store recordings:"
Info.UlFlags = &H1
PID = SHBrowseForFolder(Info)
^ --------->Info
is highlighted when the error appears
======================================

Sometimes, when creating executable, the compilier complains about that Info
above.
"Compile error: User-defined type not defined"
It usually happens after I execute code (several times) and then try to
compile program to the executable.
However, when I close vbasic and restart it again and try to compile code
there is NOT that error.

Your comments please,
Jack