473,394 Members | 1,759 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

What's wrong with this simple code? I copied if from my text book

When I build this code in Visual Studio 2005 I get and error saying: " 'Sub Main' was not found in 'ConsoleApplication2.Module1' "
" . Sub Main is there. In the online help is said is either missing or not in the correct location. I moved it to the top and it made no difference.

Imports System
Module SpillTheBeans
Private name As String
Private age As Integer
Public Sub DisplayData()
Console.WriteLine("{0} is {1}", name, age)
End Sub
Public Function GetDescription(ByVal age As Integer) As String
If age < 18 Then
Return "Minor"
Else
Return "Adult"
End If
End Function
Public Sub main()
name = "Betty"
age = 24
DisplayData()
Dim Descr As String = GetDescription(age)
Console.WriteLine("{0} is a {1}", name, Descr)
End Sub
End Module
Nov 25 '06 #1
2 1549
Set your startup object to SpillTheBeans.
To do this, double-click on your project
to show the project properties, then pick the
Application tab. Under "Startup object",
select SpillTheBeans. This is the module
containing the main routine.

I figured this out by putting your code in
a new application. Then when the error on
the build came up,I double-clicked on it,
and it came up and asked me to pick the
namespace and module containing the main
sub. Double-clicking on those errors can
be illuminating and helpful, just FYI.

Robin S.
---------------------------
"david" <da***@megnin.comwrote in message
news:p9******************@bignews2.bellsouth.net.. .
When I build this code in Visual Studio 2005 I get and error saying: "
'Sub Main' was not found in 'ConsoleApplication2.Module1' "
" . Sub Main is there. In the online help is said is either missing or
not in the correct location. I moved it to the top and it made no
difference.

Imports System
Module SpillTheBeans
Private name As String
Private age As Integer
Public Sub DisplayData()
Console.WriteLine("{0} is {1}", name, age)
End Sub
Public Function GetDescription(ByVal age As Integer) As String
If age < 18 Then
Return "Minor"
Else
Return "Adult"
End If
End Function
Public Sub main()
name = "Betty"
age = 24
DisplayData()
Dim Descr As String = GetDescription(age)
Console.WriteLine("{0} is a {1}", name, Descr)
End Sub
End Module

Nov 25 '06 #2
David,

Did you create your project at startup as console project.
Than you won't have this trouble, it is a little bit not done well in my
idea in VB 2005, in 2002/3 version there was no problem.

You know that there is a special newsgroup for VB.Net problems.

microsoft.public.dotnet.languages.vb

Cor

"david" <da***@megnin.comschreef in bericht
news:p9******************@bignews2.bellsouth.net.. .
When I build this code in Visual Studio 2005 I get and error saying: "
'Sub Main' was not found in 'ConsoleApplication2.Module1' "
" . Sub Main is there. In the online help is said is either missing or
not in the correct location. I moved it to the top and it made no
difference.

Imports System
Module SpillTheBeans
Private name As String
Private age As Integer
Public Sub DisplayData()
Console.WriteLine("{0} is {1}", name, age)
End Sub
Public Function GetDescription(ByVal age As Integer) As String
If age < 18 Then
Return "Minor"
Else
Return "Adult"
End If
End Function
Public Sub main()
name = "Betty"
age = 24
DisplayData()
Dim Descr As String = GetDescription(age)
Console.WriteLine("{0} is a {1}", name, Descr)
End Sub
End Module

Nov 25 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
41
by: Mountain Bikn' Guy | last post by:
What is the current preferred way to save user preferences in dotnet? Is the registry the right place to do this? Can anyone recommend a good article (or book) for this topic? Thanks.
4
by: Jozef | last post by:
Hello, I'm doing the lessons out of a Sams ASP.net book and have copied the following verbatim, out of the book (without the beginning and ending quotes); "'<%@ Page Language="vb"%>...
26
by: K.J.Williams | last post by:
Hello, A friend and I want to learn PHP but we have two totally different programming backgrounds. I have experience with procedural programming in C, and he has experience with Visual BASIC....
8
by: watkinsdev | last post by:
Hi, I have created a mesh class in visual studio 6.0 c++. I can create a device, render objects and can edit the objects by for instancnce selecting a cluster of vertices and processing the...
10
by: JoeC | last post by:
I have been programming for a while and I have seen this syntax before and I copied this from a book but the book didn't explain what is going on here. class engine{ protected: static engine*...
12
by: anantraoneel | last post by:
Hi Friend My project is a Library System. In Project is Book Master form. If I've select Book Type from Type Master and Publication from Publication Master then this error has come: "Arguments...
20
by: Daniel.C | last post by:
Hello. I just copied this code from my book with no modification : #include <stdio.h> /* count characters in input; 1st version */ main() { long nc; nc = 0;
6
by: Tony Johansson | last post by:
Hello! I'm reading in a book called Visual C# 2005. In the chapter about Generics there ia a section about Nullable types. Here is the text that isn't complete true I think. It says: "You...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.