I am doing a simple cash register program. I need to have a input box pop up and allow me to input costs and it needs to display them subtotal , tax and total output. The loop ends when I hit cancel button on the InputBox. I have not been able to get it to work. I have been able to get the following to work.
Option Strict On
Option Explicit On
Public Class Form1
Dim var1 As Date = DateValue("June 9, 2012")
Dim tax As Double
Dim total_sales As Double = 0.0
Dim total_due As Double = 0.0
Dim count As Integer = 0
Dim arr(15) As Double
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
arr(count) = Convert.ToDouble(TextBox1.Text)
total_sales = total_sales + arr(count)
TextBox1.Text = ""
count = count + 1
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim i As Integer
Dim result As String
i = 0
result = "Acme Sales" & vbNewLine & MonthName(Month(var1)) & " " & var1.Day & ", " & var1.Year & vbNewLine & vbNewLine
tax = total_sales * (5 / 100)
total_due = total_sales + tax
While (i < count)
result += "Item " & (i + 1) & " " & arr(i) & vbNewLine
i = i + 1
End While
result += vbNewLine & "Total Sale " & total_sales & vbNewLine
result += "Tax " & tax & vbNewLine & vbNewLine
result += "Total Due " & total_due
MessageBox.Show(result)
Me.Dispose()
End Sub
End Class
Can someone tell me how to change the code to use an input box instead of a textbox.
Option Strict On
Option Explicit On
Public Class Form1
Dim var1 As Date = DateValue("June 9, 2012")
Dim tax As Double
Dim total_sales As Double = 0.0
Dim total_due As Double = 0.0
Dim count As Integer = 0
Dim arr(15) As Double
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
arr(count) = Convert.ToDouble(TextBox1.Text)
total_sales = total_sales + arr(count)
TextBox1.Text = ""
count = count + 1
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim i As Integer
Dim result As String
i = 0
result = "Acme Sales" & vbNewLine & MonthName(Month(var1)) & " " & var1.Day & ", " & var1.Year & vbNewLine & vbNewLine
tax = total_sales * (5 / 100)
total_due = total_sales + tax
While (i < count)
result += "Item " & (i + 1) & " " & arr(i) & vbNewLine
i = i + 1
End While
result += vbNewLine & "Total Sale " & total_sales & vbNewLine
result += "Tax " & tax & vbNewLine & vbNewLine
result += "Total Due " & total_due
MessageBox.Show(result)
Me.Dispose()
End Sub
End Class
Can someone tell me how to change the code to use an input box instead of a textbox.