Hi guys. I'm doing a program that will calculate the new price. Iv been using a class to put my code their. Iv been getting errors in my form code.
Heres the class code
Here's my form codeCode:Public Class Computer
Private _id As String
Private _price As Decimal
Public Property Id() As String
Get
Return _id
End Get
Set(ByVal value As String)
End Set
End Property
Public Property Price() As Decimal
Get
Return _price
End Get
Set(ByVal value As Decimal)
End Set
End Property
Public Sub New()
_id = String.Empty
_price = 0D
End Sub
Public Sub New(ByVal model As String, ByVal cost As Decimal)
Id = model
Price = cost
End Sub
Public Function CalcNewPrice(ByVal discountPercent As Decimal) As Decimal
Return _price - _price * discountPercent / 100
End Function
the error is in the Computer.Price , Computer.CalcNewPrice and Computer.IDCode:Dim computerPurchased As New Computer
Dim isConverted As Boolean
Dim rate As Decimal
Dim newPrice As Decimal
isConverted = Decimal.TryParse(origTextBox.Text, Computer.Price)
If isConverted Then
Computer.Id = modelTextBox.Text
rate = Convert.ToDecimal(discountListBox.SelectedItem.ToString.TrimEnd("%"c))
newPrice = Computer.CalcNewPrice(rate)
newLabel.Text = newPrice.ToString("C2")
Else
MessageBox.Show("The cost must be numeric.", "Computer Workshop", _
MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End Sub
it says Reference to a non-shared member requires an object reference.

