So in my class we have an assignment to create a cash register. I got it to work fine originally but the assignment calls for a class called CashRegister(which I have never done before), a property called Balance, and add method and a subtract method. So I tried to do that but now all my text boxes, when I reference them, are giving me the error "reference to a nonshared member..". HOw do i fix this? My code is:
ANy help would be appreciated?Code:Public Class frmRegister Private Sub frmRegister_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If txtBalance.Text = "" Then txtBalance.Text = "0" End If End Sub Class CashRegister Private Balance As Integer Private addAmount As Double Private subAmount As Double Public Property AddMethod As Double Get Return addAmount End Get Set(ByVal value As Double) Dim x As Integer = Val(txtAmount.Text) Dim y As Integer = Val(txtBalance.Text) addAmount = x + y End Set End Property Public Property SubtractMethod As Double Get Return subAmount End Get Set(ByVal value As Double) Dim x As Integer = Val(txtAmount.Text) Dim y As Integer = Val(txtBalance.Text) subAmount = y - x End Set End Property Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click txtBalance.Text = FormatCurrency(addAmount) End Sub Private Sub btnSubtract_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubtract.Click txtBalance.Text = FormatCurrency(subAmount) If txtBalance.Text < 0 Then MessageBox.Show("Transaction Cannot Result in Negative Balance!") txtBalance.Text = "0" End If End Sub End Class End Class




Reply With Quote
