Results 1 to 7 of 7

Thread: Define a Public Sub?

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2002
    Location
    Norway
    Posts
    11

    Define a Public Sub?

    Okey, I'm on the road again.

    My code all ready and done BUT I get the following error:

    "Define a Public Sub Main procedure for your project. Declare it as Shared if and only if you define it inside a class"

    Now how do I "define" this?

    I've got a Public Sub Main() and a End Sub of course but nothing inside it... All my code is behind a button.

    Hard getting used to all this .NET stuff... boot cool

    : Todd

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Right click on the Project and check in the properties to make sure you have a valid form set as the startup object. If you change the name of the form sometimes the IDE doesn't pick it up and thinks there is no startup form and so it prompts you for a Sub Main.

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2002
    Location
    Norway
    Posts
    11

    Shoot, sorry about double posting

    Shoot, sorry about double posting.

    I didn't quite catch that one? Can you explain it more clearly please?

    Todd

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Right click on the project in the Solution Explorer and choose Properties from the context menu. That will bring up the property page and you can choose a startup object from there:


  5. #5

    Thread Starter
    New Member
    Join Date
    Nov 2002
    Location
    Norway
    Posts
    11

    Done that now.

    Okey, thanx. Now I've done that boot still I get an error trying to build it.

    First the Visual Studio tells me that the Project1.exe is missing so there it cannot debug since the debug target is missing. Whats that all about?

    In the task list shown after I've built the project (and failed) I get this message:

    "No accessible 'Main' method with an appropriate signature was found in 'Project1.Counter2'."

    "I was put on this earth to accomplish a certain number of things,
    right now I'm so far behind I'll never die"

    : Todd

  6. #6
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    What is Counter2 in your project? Is it a module? A form?

    Are you referencing another project?

    It sounds like you referenced Project1 and it hasn't been built or has been deleted from the bin folder of the current project. Check your references for a yellow cation icon with an exclamation on it. That indicates a bad reference, if you find one then delete/remove it. If you really need to reference that item then just re-reference it.

  7. #7

    Thread Starter
    New Member
    Join Date
    Nov 2002
    Location
    Norway
    Posts
    11

    Counter2

    ****er2 is the name of the form.
    IS this wrong? Shouldn't there be any numbers in a name? Got a hard time believeing that.

    Should I name it what it was originally called? UserForm1 or someting...?

    I'm not reffering to anything outside the project....

    I know it's stupis to call the textboxew counterTWO and so on instead of counter2 and so on, but that's the way I happend to do it. It really doesn't matter though....

    I left out all the code generated by IDE.

    ------------------------------------------------------------------------------
    VB.NET code
    ------------------------------------------------------------------------------
    Public Sub Main()

    End Sub

    Public Function bin(ByVal x As Integer) As String

    While x
    bin = IIf(x Mod 2, "1", "0") & bin(Me.counter.Text)
    x = x \ 2
    End While

    End Function

    Public Sub Button1_Click()


    Me.counter.Text = Me.counter.Text + 1
    Me.counterTWO.Text = Hex(Me.counterTWO.Text)
    Me.counterTHREE.Text = bin(Me.counter.Text)

    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width