Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. "Too many arguments to Public Sub New()"

"Too many arguments to Public Sub New()"

Scheduled Pinned Locked Moved Visual Basic
helplearning
6 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tanstaafl28
    wrote on last edited by
    #1

    I seem to be running into recurring problems with doing book exercises where my code looks exactly the same as the author's, but theirs works and mine has some sort of syntax error. my latest is: "Too many arguments to Public Sub New()" The bolded line has the blue squiggly under (Me) Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click **Dim f2 As New Form2(Me)** f2.Show() Me.Hide() End Sub Private Sub Button2_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button2.Click Dim f2 As New Form2 f2.Show() End Sub End Class Still coaxing software out of the can after all these years...

    V D 2 Replies Last reply
    0
    • T tanstaafl28

      I seem to be running into recurring problems with doing book exercises where my code looks exactly the same as the author's, but theirs works and mine has some sort of syntax error. my latest is: "Too many arguments to Public Sub New()" The bolded line has the blue squiggly under (Me) Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click **Dim f2 As New Form2(Me)** f2.Show() Me.Hide() End Sub Private Sub Button2_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button2.Click Dim f2 As New Form2 f2.Show() End Sub End Class Still coaxing software out of the can after all these years...

      V Offline
      V Offline
      VenkatFor NET
      wrote on last edited by
      #2

      You need to change the constructor of the form 'form2' such that it accepts a parameter of type 'form1' if you are in the current form. Constructor of the form 'form2' goes like this Sub New ( f as Form1 ) ...Code goes here End Sub Bhaskara

      1 Reply Last reply
      0
      • T tanstaafl28

        I seem to be running into recurring problems with doing book exercises where my code looks exactly the same as the author's, but theirs works and mine has some sort of syntax error. my latest is: "Too many arguments to Public Sub New()" The bolded line has the blue squiggly under (Me) Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click **Dim f2 As New Form2(Me)** f2.Show() Me.Hide() End Sub Private Sub Button2_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button2.Click Dim f2 As New Form2 f2.Show() End Sub End Class Still coaxing software out of the can after all these years...

        D Offline
        D Offline
        Dave Kreskowiak
        wrote on last edited by
        #3

        tanstaafl28 wrote: Dim f2 As New Form2(Me) f2.Show() Me.Hide() End Sub You don't need the Me in the constructor for Form2, unless you intend on passing Form1 as a reference to Form2 for some reason. Usually this would be because Form2 has code on it that modifies the instance, or controls, on Form1. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

        T 1 Reply Last reply
        0
        • D Dave Kreskowiak

          tanstaafl28 wrote: Dim f2 As New Form2(Me) f2.Show() Me.Hide() End Sub You don't need the Me in the constructor for Form2, unless you intend on passing Form1 as a reference to Form2 for some reason. Usually this would be because Form2 has code on it that modifies the instance, or controls, on Form1. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

          T Offline
          T Offline
          tanstaafl28
          wrote on last edited by
          #4

          While I am beginning to become more intuitive with the code, the "me" is printed in the book just as I typed it. Still coaxing software out of the can after all these years...

          D 1 Reply Last reply
          0
          • T tanstaafl28

            While I am beginning to become more intuitive with the code, the "me" is printed in the book just as I typed it. Still coaxing software out of the can after all these years...

            D Offline
            D Offline
            Dave Kreskowiak
            wrote on last edited by
            #5

            Where did this book come from? It sounds like it has a mountain of errors in it... RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

            T 1 Reply Last reply
            0
            • D Dave Kreskowiak

              Where did this book come from? It sounds like it has a mountain of errors in it... RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

              T Offline
              T Offline
              tanstaafl28
              wrote on last edited by
              #6

              It's actually several books. That's what worries me. One is Visual Basic.Net Step-by-Step by Mike Halvorson, one is Visual Basic.Net Programming by Peter Aiken, and the other one is the MCAD/MCSD Windows Aps with VB.Net and C# 2nd Edition. None of them have caused any sort of major exceptions, but I've had to do some sort of "tweaking" to my code to avoid syntax errors that they don't seem to have. So in one way, I'm learning how to improvise, but in another, I'm not getting the same results as these (so called) experts in the field. Still coaxing software out of the can after all these years...

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups