|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
'Form1' is a type in 'XXX.Module1' and cannot be used as an expression.I have this error when I try buiding a VB project:
Error 1 'Form1' is a type in 'XXX.Module1' and cannot be used as an expression. C:\code\vbstuff\Form1.vb 0 0 I am a C++ programmer and have played with VB6 in the past, but it seems a lot has changed since then. The worst thing (read most annoying thing) about this error is that the line number is given as 0, so I have absolutely no idea as to what is causing it. Anyone knows how to fix this? BTW, the fix proposed by the article in the MS knowledgebase does not really address this issue - at least, It did not fix the issue when I followed the instructions. It sounds like you are using a type, where an instance is required. Check
your code for references to "Form1" and ensure that before your use that term, you have an instatiated object with that name. Show quoteHide quote "Anonymous" <no.re***@here.com> wrote in message news:wfednQ6STZz2Z6faRVnytAA@bt.com... >I have this error when I try buiding a VB project: > > Error 1 'Form1' is a type in 'XXX.Module1' and cannot be used as an > expression. C:\code\vbstuff\Form1.vb 0 0 > > I am a C++ programmer and have played with VB6 in the past, but it seems a > lot has changed since then. > > The worst thing (read most annoying thing) about this error is that the > line number is given as 0, so I have absolutely no idea as to what is > causing it. > > Anyone knows how to fix this? BTW, the fix proposed by the article in the > MS knowledgebase does not really address this issue - at least, It did not > fix the issue when I followed the instructions. I have had this before and it seems to be a "gotcha" of the form auto-code
generation and the form "compiler"/designer which does loads of stuff "behind your back". So - make sure the form has a default constructor ? If you created your own constructor e.g. Public Sub New(ByVal value As string) InitializeComponent() End Sub Then the form needs the default construtor: Public Sub New() ' This call is required by the Windows Form Designer. InitializeComponent() ' Add any initialization after the InitializeComponent() call. End Sub The gotcha for me was that I used the entity-method dropdowns in VS IDE to add a "New" method and then EDITED the signature (added parameter) as above and the form no longer had a default New constructor. On Nov 14, 7:36 am, Anonymous <no.re***@here.com> wrote:
Show quoteHide quote > I have this error when I try buiding a VB project: Can you post a short program demonstrating the problem?> > Error 1 'Form1' is a type in 'XXX.Module1' and cannot be used as an > expression. C:\code\vbstuff\Form1.vb 0 0 > > I am a C++ programmer and have played with VB6 in the past, but it seems > a lot has changed since then. > > The worst thing (read most annoying thing) about this error is that the > line number is given as 0, so I have absolutely no idea as to what is > causing it. > > Anyone knows how to fix this? BTW, the fix proposed by the article in > the MS knowledgebase does not really address this issue - at least, It > did not fix the issue when I followed the instructions.
Shadow Copy Wrapper?
Build a string for arithmetic operation clearing dataset or datatable Force form to foreground? Using an Excel sheet as a DB table Replacing control arrays in .NET Structures and Delegates and ByRef Arguments Split a large application Why does BinaryWriter write garbage before my stuff Setup windows service |
|||||||||||||||||||||||