Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > compiling error


Reply
 
Thread Tools Display Modes
  #1  
Old 02-24-2005, 02:51 PM
angeleye1963 angeleye1963 is offline
Newcomer
 
Join Date: Aug 2004
Posts: 13
Unhappy compiling error


I found a class module and form to incorparate into my database program, when I run the programm it works fine, but when I try to compile I get an error saying:
User defined typed not defined.

the orginal program I dl compiles fine, but since I add the form and class module to my project it does not compile, i get that error. Any help please Thanks
Reply With Quote
  #2  
Old 02-24-2005, 02:58 PM
Baaklar Baaklar is offline
Centurion
 
Join Date: Mar 2003
Location: Omaha, Nebraska
Posts: 197
Default

Your program runs fine in debug mode most likely because the code path you took didn't execute a subroutine/function that uses the missing UDT. When you compile, it checks everything.

Try attaching the class module you downloaded. It's hard to know which UDT is missing without seeing the code itself.

Try it yourself though, and step through the class module's code and see what's missing.
Reply With Quote
  #3  
Old 02-24-2005, 03:33 PM
reboot's Avatar
reboot reboot is offline
Keeper of foo

Retired Moderator
* Guru *
 
Join Date: Nov 2001
Location: Graceland
Posts: 15,612
Default

You're missing a Reference, and as Baaklar said, we can't tell what it is unless you attach the offending code.
__________________
~ Quod non mortiferum, fortiorem me facit ~

Avatar by lebb
Reply With Quote
  #4  
Old 02-24-2005, 05:20 PM
angeleye1963 angeleye1963 is offline
Newcomer
 
Join Date: Aug 2004
Posts: 13
Default

Quote:
Originally Posted by angeleye1963
sorry, but how do i add the attachment here, I uploaded 2 times.
Here is the code:
If possible can I email someone the program to look at.
Code:
Private Const QS_MOUSEBUTTON As Long = &H4 Private Const QS_HOTKEY As Long = &H80 Private Const QS_KEY As Long = &H1 Private Const QS_PAINT As Long = &H20 Private Const QS_TIMER As Long = &H10 Private Declare Function GetQueueStatus Lib "user32" (ByVal qsFlags As Long) As Long Private Function DoEventsEx() As Long 'DoEventsEx is tested and is believed to be 100% to 800% faster then 'DoEvents. For more info, search planetsourcecode.com in the VBWorld for: 'DoEvents evolution On Error Resume Next DoEventsEx = GetQueueStatus(QS_HOTKEY Or QS_KEY Or QS_MOUSEBUTTON Or QS_PAINT Or QS_TIMER) If DoEventsEx <> 0 Then DoEvents End If End Function Public Sub ExportToCSV(ADODBRecordset As ADODB.Recordset, FilePathToExport As String, ShowProgress As ProgressBar) Dim iTotalRecords As Long, i As Long, NumberofFields As Long Dim Progress As Boolean, TotalRecords As Long On Local Error Resume Next 'Some recordsets can be pretty big 'that's why I used long and not integer Open FilePathToExport For Output Access Write As #1 With ADODBRecordset NumberofFields = .Fields.Count - 1 'It is faster to read from .MoveFirst 'memory then executing operation 'in a loop For i = 0 To NumberofFields 'Now add the field names similar Print #1, .Fields(i).Name & ","; 'to the ones below Next i Print #1, 'Go to next line With ShowProgress .Min = 0 .Max = ADODBRecordset.RecordCount .Value = 0 End With 'SHOWPROGRESS Do While Not .EOF TotalRecords = TotalRecords + 1 For i = 0 To NumberofFields 'If there is an emty field, If (IsNull(.Fields(i))) Then 'add a , to indicate it is Print #1, ","; 'empty Else '(ISNULL(.FIELDS(I))) = FALSE/0 If i = NumberofFields Then Print #1, Chr$(34) & Trim$(CStr(.Fields(i))) & Chr$(34); Else 'NOT I... Print #1, Chr$(34) & Trim$(CStr(.Fields(i))); Chr$(34) & ","; End If End If 'Putting data under "" will not Next i 'confuse the reader of the file DoEventsEx 'between Dhaka, Bangladesh as two Print #1, 'fields or as one field . .MoveNext 'Chr(34) is doublequote ShowProgress.Value = ShowProgress.Value + 1 Loop End With 'ADODBRECORDSET Close #1 End Sub Public Sub ExportToExcel(ADODBRecordset As ADODB.Recordset, ShowProgress As ProgressBar) Dim i As Integer, iRowIndex As Integer, avRows As Variant Dim iColIndex As Integer, iRecordCount As Integer, objTemp As Object Dim iFieldCount As Integer, xCELver As Byte, [U]objExcel As Excel.Application[/U]this is the offending line. On Local Error Resume Next With ShowProgress .Min = 0 .Max = ADODBRecordset.RecordCount .Value = 0 End With 'SHOWPROGRESS With ADODBRecordset .MoveFirst avRows = .GetRows() 'Read all the records iRecordCount = UBound(avRows, 2) + 1 'in an array and iFieldCount = UBound(avRows, 1) + 1 'determine how many 'fields in an array Set objExcel = CreateObject("Excel.Application") objExcel.Visible = True objExcel.Workbooks.Add 'Ensure Excel remains visible if we change to active sheet Set objTemp = objExcel If xCELver >= 8 Then Set objExcel = objExcel.ActiveSheet End If iRowIndex = 1 iColIndex = 1 'Place Name of the fields For iColIndex = 1 To iFieldCount 'As coloumn headers with With objExcel.Cells(iRowIndex, iColIndex) 'a better font then Sans .Value = ADODBRecordset.Fields(iColIndex - 1).Name 'Serif With .Font .Name = "Tahoma" .Bold = True .Size = 9 End With '.FONT End With 'OBJEXCEL.CELLS(IROWINDEX, Next iColIndex End With 'ADODBRECORDSET With objExcel 'Go Baby GO! Add DATA! For iRowIndex = 2 To iRecordCount + 1 'BEAUTIFUL DATA! For iColIndex = 1 To iFieldCount 'MY DATA! .Cells(iRowIndex, iColIndex) = avRows(iColIndex - 1, iRowIndex - 2) ShowProgress.Value = iRowIndex DoEventsEx Next iColIndex Next iRowIndex .Cells(1, 1).CurrentRegion.EntireColumn.AutoFit 'Autofit for good looks End With 'OBJEXCEL End Sub Public Sub ExportToHTML(ADODBRecordset As ADODB.Recordset, FilePathToExport As String, TitleOfHTML As String, ShowProgress As ProgressBar) Dim TotalRecords As Long, i As Integer, Progress As Boolean Dim NumberofFields As Long On Local Error Resume Next Open FilePathToExport For Output As #1 Print #1, "<HTML><HEAD><TITLE> " & TitleOfHTML & " </TITLE></HEAD>" Print #1, "<BODY BGCOLOR=""FFFFFF"">" Print #1, "<TABLE BGCOLOR=""00AAFF"" WIDTH=""100%"">" Print #1, "<TR><TD>" Print #1, "<FONT FACE=ARIAL SIZE+=3><B>" & TitleOfHTML & "</B></font></td></tr>" Print #1, "<TR>" 'First add all the usual With ADODBRecordset 'HTML Tags to the ASCII .MoveFirst 'File (with color). For i = 0 To .Fields.Count - 1 Print #1, "<TD BGCOLOR=CCCCC>" 'Now add the titles to the Print #1, "<B>"; .Fields(i).Name; "</B>" 'file. Make sure they Print #1, "</TD>" 'Stand out. Next i Print #1, "</TR>" .MoveFirst With ShowProgress .Min = 0 .Max = ADODBRecordset.RecordCount .Value = 0 End With 'SHOWPROGRESS Do While Not .EOF Print #1, "<TR>" 'Add database records in HTML Format For i = 0 To .Fields.Count - 1 Print #1, "<TD BGCOLOR=CCCCC>" Print #1, .Fields(i); "&nbsp" 'I am having problem Print #1, "</TD>" 'appending null values DoEventsEx 'Mail your suggestion Next i 'to [email]elv15@toughguy.net[/email] Print #1, "</TR>" .MoveNext ShowProgress.Value = ShowProgress.Value + 1 Loop End With 'ADODBRECORDSET Print #1, "</TABLE></BODY></HTML>" 'Complete the ASCII HTML Close #1 'File End Sub

Last edited by lebb; 02-24-2005 at 09:24 PM.
Reply With Quote
  #5  
Old 02-24-2005, 06:50 PM
MikeJ's Avatar
MikeJ MikeJ is offline
Retread

Retired Moderator
* Expert *
 
Join Date: Sep 2002
Location: Austin, Texas
Posts: 6,742
Default

Did you remember to reference the Excel Object Library? (Project > References > ...)
__________________
{ Lex Fori } { Locus Classicus } { Rutilus Scrinium }
Osculare pultem meam!
Reply With Quote
  #6  
Old 02-25-2005, 09:50 AM
angeleye1963 angeleye1963 is offline
Newcomer
 
Join Date: Aug 2004
Posts: 13
Default

Quote:
Originally Posted by MikeJ
Did you remember to reference the Excel Object Library? (Project > References > ...)
No I did not do that, but I do not see the excel object library in the list, is there another library that I must use.
Reply With Quote
  #7  
Old 02-25-2005, 09:53 AM
angeleye1963 angeleye1963 is offline
Newcomer
 
Join Date: Aug 2004
Posts: 13
Default

Quote:
Originally Posted by angeleye1963
No I did not do that, but I do not see the excel object library in the list, is there another library that I must use.
ok, I found it, and I can know compile without any error, Can you explain what and why I needed to reference that object, I sure would appreciate it. Thanks for the help Lori
Reply With Quote
  #8  
Old 02-25-2005, 10:19 AM
grahamt grahamt is offline
Junior Contributor
 
Join Date: Feb 2005
Posts: 247
Default

Because of this line

Code:
Dim iFieldCount As Integer, xCELver As Byte, objExcel As Excel.Application
Reply With Quote
  #9  
Old 02-25-2005, 11:54 AM
HardCode's Avatar
HardCode HardCode is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Feb 2004
Location: New Jersey
Posts: 3,338
Default

To expand on that, while your PC "knows about" the Excel DLL installed on your machine, your default VB application doesn't. In order to use the functionality of a DLL that you see in Project --> References, you need to check the box to make the VB program "aware" of the DLL. Once that is done, like with Excel in this case, you can use all of the functionality that the DLL offers.
__________________
DON'T CLICK HERE

Useful forum tags: [VB][/VB], [CODE][/CODE], [HTML][/HTML]
Reply With Quote
  #10  
Old 02-25-2005, 04:36 PM
angeleye1963 angeleye1963 is offline
Newcomer
 
Join Date: Aug 2004
Posts: 13
Default

Quote:
Originally Posted by HardCode
To expand on that, while your PC "knows about" the Excel DLL installed on your machine, your default VB application doesn't. In order to use the functionality of a DLL that you see in Project --> References, you need to check the box to make the VB program "aware" of the DLL. Once that is done, like with Excel in this case, you can use all of the functionality that the DLL offers.
Ok, so DLL are commonly used procedures, already coded for Vb to use, then I only have to call the DLL to be used in any of my produres. I am embedding or link the excel object, I have a reference of the link object, but the object is actually kept in other applications.
Reply With Quote
  #11  
Old 02-25-2005, 04:40 PM
theHollow theHollow is offline
Newcomer
 
Join Date: Jan 2005
Location: Moss, Norway, Europe
Posts: 8
Default

I always add the line

Option Explicit

In the top of every form and module. Good rule of thumb.

//theHollow
Reply With Quote
  #12  
Old 02-25-2005, 06:51 PM
reboot's Avatar
reboot reboot is offline
Keeper of foo

Retired Moderator
* Guru *
 
Join Date: Nov 2001
Location: Graceland
Posts: 15,612
Default

You know VB can be set to always add it for you.... better rule of thumb.
__________________
~ Quod non mortiferum, fortiorem me facit ~

Avatar by lebb
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->