I am trying to implement some VB.NET code that takes the credit card details from a web form and passes them into the payment object. I've done this for the personal details form on another page, which worked fine.
However, on this page I am getting the Too many arguments to Public Sub New() error for the following line:
Dim cardDetails As Payment = New Payment(Me.CardNumber.Text, Me.CardExpiryMonth.Text, Me.CardExpiryYear.Text)
This is the part that doesn't make any sense. It requires three arguments, and I'm sending it three arguments. There really isn't much more information to give. The below is both the code behind and the payment class.
In Payment.vb:
Imports Microsoft.VisualBasic
Public Class Payment
'declare variables, private
Private cardNo As String
Private expiryMth As String
Private expiryYr As String
''get and set for each variable
Private Property cardNumber() As String
Get
Return cardNo
End Get
Set(value As String)
cardNo = value
End Set
End Property
Private Property expiryMonth() As String
Get
Return expiryMth
End Get
Set(value As String)
expiryMth = value
End Set
End Property
Private Property expiryYear() As String
Get
Return expiryYr
End Get
Set(value As String)
expiryYr = value
End Set
End Property
'no argument constructor
Public Sub New()
End Sub
''sub methods/functions do stuff and return values
Public Overrides Function ToString() As String
Return cardNo
End Function
Public Sub New(ByVal cardNumber As String, ByVal expiryMonth As String, ByVal expiryYear As String)
End Sub
End Class
And in Payment.aspx.vb I have:
Protected Sub Submit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Submit.Click
'add the card details from the form to the object.
Dim cardDetails As Payment = New Payment(Me.CardNumber.Text, Me.CardExpiryMonth.Text, Me.CardExpiryYear.Text)