Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 06-23-2005, 07:16 AM   #1 (permalink)
 
True Techie

Join Date: Dec 2004

Posts: 145

Mohan Giri

Default Vb.Net Submain Error

Hi everyone,
I have created one console application in vb.net and included one module. In the module I used one sub main. If I compile this I got a error like:

'Sub Main' was not found in 'ConsoleApplication1'.

I searched for this in Google. I got a solution for this. In the solution they told to change the Startup Object to "Sub main" from "Module1" in the console application's project. I did it. Eventhough I am getting the same error. Anybody can help me??

Advance thanks.
Mohan Giri is offline  
Old 06-23-2005, 10:04 AM   #2 (permalink)
 
Ultra Techie

Join Date: Sep 2003

Location: Bamberg, Germany

Posts: 549

Iron_Cross

Send a message via ICQ to Iron_Cross Send a message via MSN to Iron_Cross Send a message via Yahoo to Iron_Cross
Default

post your code.

My guess is that you might need to use a function rather than a sub...but again, just post your code.
__________________

See today\'s Penny-Arcade!(May contain foul lanuage)
Pain is weakness leaving the body.

PM Me for my MSN
Iron_Cross is offline  
Old 06-23-2005, 11:05 AM   #3 (permalink)
 
True Techie

Join Date: Dec 2004

Posts: 145

Mohan Giri

Default

Ok. Here is my code Mr.Iron_Cross.

Module advice
Public Class Wisdom
Delegate Function GiveAdvice() As String
Public Function Offeradvice(ByVal words As GiveAdvice) As String
Return (words())
End Function
End Class

Public Class Parent 'base type
Public Overridable Function Message() As String
Return ("You should listen to your elders")
End Function
End Class

Public Class Dad 'derived from the base parent type
Inherits Parent
Public Overrides Function Message() As String
Return ("You should listen to your mom")
End Function
End Class

Public Class Mom 'derived from the base parent type
Inherits Parent
Public Overrides Function Message() As String
Return ("You should listen to your Dad")
End Function
End Class

Public Class Daughter 'not derived from the base parent type
Public Function Message() As String
Return ("I know all there is to life")
End Function
End Class

Public Function CallAdvice(ByVal p As Parent) As String
Dim objParents As New Wisdom
Dim TeenAgeGirl As Wisdom.GiveAdvice = New Wisdom.GiveAdvice(AddressOf p.Message)
Return (objParents.Offeradvice(TeenAgeGirl))
End Function

Sub MainMenu()
Dim objDad As New Dad
Dim objmom As New Mom
Dim objDaughter As New Daughter
Console.WriteLine(CallAdvice(objDad))
Console.WriteLine(CallAdvice(objmom))

'will not work as this is not derived
'Console.WriteLine(CallAdvice(objDaughter))
End Sub
End Module
Mohan Giri is offline  
Old 06-23-2005, 11:40 AM   #4 (permalink)
 
Ultra Techie

Join Date: Sep 2003

Location: Bamberg, Germany

Posts: 549

Iron_Cross

Send a message via ICQ to Iron_Cross Send a message via MSN to Iron_Cross Send a message via Yahoo to Iron_Cross
Default

I'm not seeing a "Sub Main" I'm seeing a "Sub MainMenu"...is this what you meant to do?

Also, just my two cents. I think you'd get a lot more out of using C#. Considering I've seen you asking questions about C and C++ and stuff, I really think you should switch. And since they're both .NET, you won't have to re-learn anything, the only thing different is syntax (and the syntax is much closer to C++).
__________________

See today\'s Penny-Arcade!(May contain foul lanuage)
Pain is weakness leaving the body.

PM Me for my MSN
Iron_Cross is offline  
Old 06-23-2005, 12:09 PM   #5 (permalink)
 
True Techie

Join Date: Dec 2004

Posts: 145

Mohan Giri

Default

Ok Mr.Iron_Cross. Thanks for your help.
Mohan Giri is offline  
 
Closed Thread

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On