Home All Groups Group Topic Archive Search About

vbc : error BC30420: 'Sub Main' was not found in 'Product'.

Author
25 Dec 2006 12:43 AM
Learner
Hello,

  I just wanted to jump on try creating a small calss in VB.NET in a
note pad. And my class takes below lines of code



Public Class Product

Public Name as string
Private m_id as string

Public Sub New()
  m_id = 0
End Sub

Public property ID() as Integer

Get
    ID = M_id
End Get

Set(byVal Value as Integer)
    m_id = Value
End Set

End Property

End Class



But when I run this in the command prompt I got the above error that is
mentioned in the subject line.

Now, my question is do I need to have Sub Main class to create a simple
class? I guess may be I need it when I want create an object for this
Product class and try calling its properties and methods.

Please help me understand.

Thanks
-L

Author
25 Dec 2006 1:24 AM
Herfried K. Wagner [MVP]
"Learner" <pra***@gmail.com> schrieb:
>  I just wanted to jump on try creating a small calss in VB.NET in a
> note pad. And my class takes below lines of code

Your application needs an "entry point", where execution starts.

I suggest to add a class with a shared main sub:

\\\
Public Class Program
    Public Shared Sub Main()
        Console.WriteLine("Hello World")
    End Sub
End Class
///

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
25 Dec 2006 1:37 AM
Learner
Hello,

Thanks for the quick response.

Is this some thing like this?

Public Class Product
Public shared sub Main()
Public Name as string
Private m_id as string

Public Sub New()
  m_id = 0
End Sub

Public property ID() as Integer

Get
    ID = M_id
End Get

Set(byVal Value as Integer)
    m_id = Value
End Set

End Property
End sub
End Class

Can you help modify my program?

Thanks
-L
Herfried K. Wagner [MVP] wrote:
Show quoteHide quote
> "Learner" <pra***@gmail.com> schrieb:
> >  I just wanted to jump on try creating a small calss in VB.NET in a
> > note pad. And my class takes below lines of code
>
> Your application needs an "entry point", where execution starts.
>
> I suggest to add a class with a shared main sub:
>
> \\\
> Public Class Program
>     Public Shared Sub Main()
>         Console.WriteLine("Hello World")
>     End Sub
> End Class
> ///
>
> --
>  M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
>  V B   <URL:http://classicvb.org/petition/>
Author
25 Dec 2006 1:40 AM
Learner
I just tried simply your few lines of code but it said "Console" is not
declared. Do I need to import any kind of namespace?

Thanks
-L
Herfried K. Wagner [MVP] wrote:
Show quoteHide quote
> "Learner" <pra***@gmail.com> schrieb:
> >  I just wanted to jump on try creating a small calss in VB.NET in a
> > note pad. And my class takes below lines of code
>
> Your application needs an "entry point", where execution starts.
>
> I suggest to add a class with a shared main sub:
>
> \\\
> Public Class Program
>     Public Shared Sub Main()
>         Console.WriteLine("Hello World")
>     End Sub
> End Class
> ///
>
> --
>  M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
>  V B   <URL:http://classicvb.org/petition/>
Author
25 Dec 2006 11:46 AM
Herfried K. Wagner [MVP]
"Learner" <pra***@gmail.com> schrieb:
>I just tried simply your few lines of code but it said "Console" is not
> declared. Do I need to import any kind of namespace?

Ooops, yes, I forgot 'Imports System' on top of the file.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>