"Too many arguments to Public Sub New()"
-
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... -
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...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
-
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...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 -
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 GnomeWhile 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...
-
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...
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
-
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
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...