472,985 Members | 2,355 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

How to rename sub main to function main

I made an console application with Visual Basic .net. Visual Basic will
automatically create the sub procedure main for you. I try to convert the
main procedure to a function.

During the compilation I will get an error message:

No accessible 'Main' method with an appropriate signature was found in
<application>.

I took a look at the following settings in Visual Basic dotnet:

Project, properties, common properties, general, start object

Here it's possible to define you startup project, but when I modify this
option, the startup object is automatically reset to Sub Main in stead of
Function Main.

Does someone know how to change this?

Thank in advance.

Kind regards,

Rody


Nov 20 '05 #1
8 3544
* "Rody Reulen" <rr*****@romacel.nl> scripsit:
I made an console application with Visual Basic .net. Visual Basic will
automatically create the sub procedure main for you. I try to convert the
main procedure to a function.

During the compilation I will get an error message:

No accessible 'Main' method with an appropriate signature was found in
<application>.

I took a look at the following settings in Visual Basic dotnet:

Project, properties, common properties, general, start object

Here it's possible to define you startup project, but when I modify this
option, the startup object is automatically reset to Sub Main in stead of
Function Main.


Post the code you are using.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #2
Hello, Rody:

The Main() method must have public access. If it is inside a class, it must also be shared:

\\\
module MyTestModule
public sub Main()
end sub
end module

class MyTestClass
public shared sub Main()
end sub
end class
///

Regards.
"Rody Reulen" <rr*****@romacel.nl> escribió en el mensaje news:40***********************@dreader14.news.xs4a ll.nl...
| I made an console application with Visual Basic .net. Visual Basic will
| automatically create the sub procedure main for you. I try to convert the
| main procedure to a function.
|
| During the compilation I will get an error message:
|
| No accessible 'Main' method with an appropriate signature was found in
| <application>.
|
| I took a look at the following settings in Visual Basic dotnet:
|
| Project, properties, common properties, general, start object
|
| Here it's possible to define you startup project, but when I modify this
| option, the startup object is automatically reset to Sub Main in stead of
| Function Main.
|
| Does someone know how to change this?
|
| Thank in advance.
|
| Kind regards,
|
| Rody

Nov 20 '05 #3
Rody,
As Herfried stated, post your code.

Main can be a function as long as it returns an Integer.

Also you can either have an array of string as a parameter or no parameters.

For details see:

http://msdn.microsoft.com/library/de...sicModules.asp

and

http://msdn.microsoft.com/library/de...helloworld.asp

Hope this helps
Jay

"Rody Reulen" <rr*****@romacel.nl> wrote in message
news:40***********************@dreader14.news.xs4a ll.nl...
I made an console application with Visual Basic .net. Visual Basic will
automatically create the sub procedure main for you. I try to convert the
main procedure to a function.

During the compilation I will get an error message:

No accessible 'Main' method with an appropriate signature was found in
<application>.

I took a look at the following settings in Visual Basic dotnet:

Project, properties, common properties, general, start object

Here it's possible to define you startup project, but when I modify this
option, the startup object is automatically reset to Sub Main in stead of
Function Main.

Does someone know how to change this?

Thank in advance.

Kind regards,

Rody

Nov 20 '05 #4
The problem is solved now.

The reason why it did work was because I did specify:

Function Main()
' Do something

Return <integer value>
End Function

in stead of

Function Main() as Integer
'Do something

Return <integer value>
End Function

As you can see I did not explicitly specify the returnvalue type from the
function.

Thanks for you help.

Kind regards,

Rody

"Rody Reulen" <rr*****@romacel.nl> wrote in message
news:40***********************@dreader14.news.xs4a ll.nl...
I made an console application with Visual Basic .net. Visual Basic will
automatically create the sub procedure main for you. I try to convert the
main procedure to a function.

During the compilation I will get an error message:

No accessible 'Main' method with an appropriate signature was found in
<application>.

I took a look at the following settings in Visual Basic dotnet:

Project, properties, common properties, general, start object

Here it's possible to define you startup project, but when I modify this
option, the startup object is automatically reset to Sub Main in stead of
Function Main.

Does someone know how to change this?

Thank in advance.

Kind regards,

Rody

Nov 20 '05 #5
* "Rody Reulen" <rr*****@romacel.nl> scripsit:
The reason why it did work was because I did specify:

Function Main()
' Do something

Return <integer value>
End Function

in stead of

Function Main() as Integer
'Do something

Return <integer value>
End Function

As you can see I did not explicitly specify the returnvalue type from the
function.


Always do that! I would specify an access modifier explicitly too.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #6
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:OV**************@tk2msftngp13.phx.gbl...
* "Rody Reulen" <rr*****@romacel.nl> scripsit: .. . .
Function Main() as Integer .. . . Return <integer value>
End Function

.. . . I would specify an access modifier explicitly too.


Herfried,

Having never used an access modifier in this situation myself,
which would you recommend and why?

Regards,
Phill W.
Nov 20 '05 #7
* "Phill. W" <P.A.Ward@o-p-e-n-.-a-c-.-u-k> scripsit:
. . .
Function Main() as Integer . . . Return <integer value>
End Function

. . .
I would specify an access modifier explicitly too.


Herfried,

Having never used an access modifier in this situation myself,
which would you recommend and why?


'Public Sub Main'. If you don't specify a modifier, the sub will be
public too, but it's "good style" to always specify the modifier...

;-)

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #8
On Thu, 12 Feb 2004 10:32:01 +0100, Rody Reulen wrote:
The problem is solved now.

The reason why it did work was because I did specify:

Function Main()

in stead of

Function Main() as Integer


If Option Strict On was set, it should have flagged it as an error. Is
Option Strict On?

--
Chris

To send me an E-mail, remove the underscores and lunchmeat from my E-Mail
address.
Nov 20 '05 #9

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

Similar topics

7
by: Tom | last post by:
I'm having a problem using a path with spaces as a parameter to os.rename() in a program on WinXP. This works fine at the command line (where the folder "c:\aa bb" exists) > os.rename( "c\aa...
10
by: Alvaro Puente | last post by:
Hi all! Do any of you know if wildcards are accepted when calling rename() function? Thanks/Alvaro
2
by: Jason | last post by:
Why is it that whenever I rename a form from Form1 to something else it fails during the build. I get an error - Sub Main not found...... What is the problem? If I rename the form back to...
1
by: Jay at SCA | last post by:
I've been having the following issue with a windows service I've created in vb.net (.net fw 1.1): Basically, my service monitors a folder for the creation of any new files of a particular type...
8
by: Merlin | last post by:
Ok.... I feel really dumb on this one, because I had previously figured it out, and now don't have a clue. I'm trying to get the user to input a new filename (via an integer variable) and...
3
by: ehabaziz2001 | last post by:
When I rename the variables d,p TO : do,po in all the module of : void convert_meter(float *me,float *d,float *p) I got an error of that line of : void convert_meter(float *me,float *d,float *p)...
12
by: mantrid | last post by:
Im trying to move a file but am having luck my code is below. The temp and target paths are valid as they echo correctly. but I cant get the copy() function to work, or the rename() function ...
6
by: shuaishuaiyes | last post by:
Hello everyone... I'm a Chinese student and my English is very poor...So excuse me if I make grammar mistake. I want to ask some questions about "rename". I'm a beginner, so my C ..... :) I...
1
by: dsrawat | last post by:
Hi all, Does any body have any idea if i rename a Table in SQL then is it's object id in terms of Sysobjects remain same or not. I am asking because i did below in my application. 1) I...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.