Option Explicit On Option Strict On Public Class Square Private _side As Integer Private _length As Integer Private _width As Integer Public Property Side() As Integer Get Return _side End Get Set(ByVal value As Integer) If value > 0 Then _side = value Else _side = 0 End If End Set End Property Public Property Length() As Integer Get Return _length End Get Set(ByVal value As Integer) If value > 0 Then _length = value Else _length = 0 End If End Set End Property Public Property Width() As Integer Get Return _width End Get Set(ByVal value As Integer) If value > 0 Then _width = value Else _width = 0 End If End Set End Property Public Sub New() ' default constructor _side = 0 End Sub Public Function CalculateArea() As Integer<--error here says 'has multiple definitions with identical signatures' Return _side * _side End Function Public Overloads Function CalculateArea() As Integer Return _length * _width End Function End Class
Calc button code:
Private Sub xCalcButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles xCalcButton.Click 'calculates and displays the area of a square Dim mySquare As New Square Dim area As Integer 'assign side measurement to the 'Square object's property Integer.TryParse(Me.xSideTextBox.Text, mySquare.Side) 'calculate and display the area area = mySquare.CalculateArea() Me.xAreaLabel.Text = area.ToString Me.xSideTextBox.Focus() End Sub
No errors here so far..

New Topic/Question
Reply




MultiQuote





|