Cash Register Program In C
Jun 22, 2009 Hello. I wrote a cash register program as a homework for my C++ class but having some problems with it. The code partially works but not the way I.
Hello everyone; Can anyone help me fix my code? For some reason I am not able to call in the methods/functions that I created in order to do the calculation. Public Class Assignment10 Private Sub Assignment10Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If txtBalance.Text = ' Then txtBalance.Text = '0' End If End Sub Private Sub btnAddClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click txtBalance.Text = FormatCurrency(AddMethod) End Sub Private Sub btnSubtractClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubtract.Click txtBalance.Text = FormatCurrency(SubMethod) If txtBalance.Text.
You have to use an instance of the class and pass the amount to the functions. A function is normally defined as having a return value.
Download encore 4.5.3. Download Encore for Windows now from Softonic: 100% safe and virus free. More than 15 downloads this month. Download Encore latest version 2018. Sep 11, 2017 No specific info about version 4.5. Please visit the main page of GVOX Encore on Software Informer.
Give More Feedback

So people started using the term method that may or may not hae a return value. In basic it was handled by using either a subroutine (not having a return value) or function (having a retrun value). In C Language everything is called a function and when there was not return value you have to specify the return value as being 'void'. So in VS which can be either basic or C we use methods. You need two return values from the methods.
One to have the value, and the other is an error conditions. So one method is to use the parametter list to return a value like the code below.
Using ByRef allows the value inside a function to get returned back to calling method. Class CashRegister Public Balance As Integer Public addAmount As Double Public subAmount As Double Public Function AddMethod(ByVal amount As String, ByRef results As Double) As Boolean results = 0 Return True End Function End functon Public Function SubtractMethod(ByVal amount As String, ByRef results As Double) As Boolean results = 0 Return True End FunctionEnd Class jdweng. You have to use an instance of the class and pass the amount to the functions.

You have to use an instance of the class and pass the amount to the functions. This is a homework assignment and I will help to a limited degree. Right now x and y are getting the same value so you will always get a result of zero. You should put a break points in the code using F9 and then step through the code using F11 to help figure out what is wrong. YOu can hover over the variables to see the values or hightlight the variables with the mounse, then right click and select ADD WATCH. Jdweng Thanks for the reply; and thank you for helping, it is up to me after all to figure out the code. So I rewrote almost the entire code, and it is working fine.
However I have a couple of questions; Firstly, are methods the same as functions? The assignment requires methods to calculate; and I am not sure on this part.
Secondly; Am I able to put IF statements in a function? For example; if the balance becomes negative there has to be a warning message and it cannot let it happen. The instructions state ' Subtract method prevents a negative balance, displays messagebox' Does this mean it HAS to be in the function itself, or can it be in the subtract button? A function is normally defined as having a return value. So people started using the term method that may or may not hae a return value. In basic it was handled by using either a subroutine (not having a return value) or function (having a retrun value). In C Language everything is called a function and when there was not return value you have to specify the return value as being 'void'.
So in VS which can be either basic or C we use methods. You need two return values from the methods. One to have the value, and the other is an error conditions. So one method is to use the parametter list to return a value like the code below. Using ByRef allows the value inside a function to get returned back to calling method.
Class CashRegister Public Balance As Integer Public addAmount As Double Public subAmount As Double Public Function AddMethod(ByVal amount As String, ByRef results As Double) As Boolean results = 0 Return True End Function End functon Public Function SubtractMethod(ByVal amount As String, ByRef results As Double) As Boolean results = 0 Return True End FunctionEnd Class jdweng. A function is normally defined as having a return value. So people started using the term method that may or may not hae a return value. In basic it was handled by using either a subroutine (not having a return value) or function (having a retrun value). In C Language everything is called a function and when there was not return value you have to specify the return value as being 'void'. So in VS which can be either basic or C we use methods. You need two return values from the methods.
One to have the value, and the other is an error conditions. So one method is to use the parametter list to return a value like the code below. Using ByRef allows the value inside a function to get returned back to calling method. Class CashRegister Public Balance As Integer Public addAmount As Double Public subAmount As Double Public Function AddMethod(ByVal amount As String, ByRef results As Double) As Boolean results = 0 Return True End Function End functon Public Function SubtractMethod(ByVal amount As String, ByRef results As Double) As Boolean results = 0 Return True End Function End Class jdweng Thanks for the reply; I am still slightly confused on how to use that code. Do i use an IF statement in order to detect if the Balance is.
Create a new class for the item so you can have it as an object, then override the to string to display the text as you want it.