estou fazendo um programa frente caixa porém na hora de receber o calculo de valores dar errado o total e no dinheiro do cliente o calculo do troco sai inteiro já coloquei decimal e outras tags mais mesmo assim não sai certo o codico abaixo para exemplo
Imports System.IO
Imports System.Security.Cryptography
Imports System.Text
Public Class frmPayment
#Region "Controlbox"
Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
Me.Close()
LstOrder.Items.Clear()
txtTotal.Clear()
txtDinheiro.Text = "0,00"
txtTroco.Text = "0,00"
End Sub
#End Region
Public Shared Function GetUniqueKey(ByVal maxSize As Integer) As String
Dim chars As Char() = New Char(91) {}
chars = "123456789".ToCharArray()
Dim data As Byte() = New Byte(0) {}
Dim crypto As New RNGCryptoServiceProvider()
crypto.GetNonZeroBytes(data)
data = New Byte(maxSize - 1) {}
crypto.GetNonZeroBytes(data)
Dim result As New StringBuilder(maxSize)
For Each b As Byte In data
result.Append(chars(b Mod (chars.Length)))
Next
Return result.ToString()
End Function
Private Sub txtCash_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtDinheiro.TextChanged
txtTroco.Text = Format(Val(txtDinheiro.Text) - Val(txtTotal.Text), "#,##0.00")
End Sub
Private Sub BtnConcluido_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnConcluido.Click
If Val(txtTotal.Text) > Val(txtDinheiro.Text) Then
MessageBox.Show("Informe um valor maior ou igual ao valor total.", "Valor inválido", MessageBoxButtons.OK, MessageBoxIcon.Error)
Else
Dim prodname As String = ""
'If frmMenu.prod.StartsWith(",") = True Then
' prodname = frmMenu.prod.Remove(0, 1)
'End If
For i = 0 To Me.LstOrder.Items.Count - 1
prodname = prodname & "," & LstOrder.Items(i).ToString.Replace("& vbcrlf", "")
Next i
If prodname.StartsWith(",") = True Then
prodname = prodname.Remove(0, 1)
End If
Dim trpath As String = Application.StartupPath & "\Record\Registro.txt"
File.AppendAllText(trpath, ReceitaNo.Text & " | " & Format(Date.Now, "dd/MM/yyyy") & " | " & prodname.Trim & " | " & txtTotal.Text & " | " & Format(Val(txtDinheiro.Text), "#,###.00") & " | " & txtTroco.Text & vbCrLf)
With frmReceipt
For i = 0 To Me.LstOrder.Items.Count - 1
.LstOrder.Items.Add(LstOrder.Items(i))
Next i
.ReceiptNo.Text = Me.ReceitaNo.Text
.lblTotal.Text = Me.txtTotal.Text
.lblCash.Text = Me.txtDinheiro.Text
.lblChange.Text = Me.txtTroco.Text
.ShowDialog()
End With
prodname = ""
btnClose_Click(sender, e)
frmMenu.BtnClear_Click(sender, e)
frmMenu.dtgRecord.Rows.Clear()
frmMenu.Filter_Record()
End If
End Sub
Private Sub frmPayment_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ReceitaNo.Text = "BURGER-" & GetUniqueKey(6)
End Sub
Private Sub LstOrder_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LstOrder.SelectedIndexChanged
End Sub
Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click
End Sub
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
End Sub
Private Sub txtTotal_TextChanged(sender As Object, e As EventArgs) Handles txtTotal.TextChanged
Pergunta
alex marques profissional
estou fazendo um programa frente caixa porém na hora de receber o calculo de valores dar errado o total e no dinheiro do cliente o calculo do troco sai inteiro já coloquei decimal e outras tags mais mesmo assim não sai certo o codico abaixo para exemplo
Imports System.IO
Imports System.Security.Cryptography
Imports System.Text
Public Class frmPayment
#Region "Controlbox"
Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
Me.Close()
LstOrder.Items.Clear()
txtTotal.Clear()
txtDinheiro.Text = "0,00"
txtTroco.Text = "0,00"
End Sub
#End Region
Public Shared Function GetUniqueKey(ByVal maxSize As Integer) As String
Dim chars As Char() = New Char(91) {}
chars = "123456789".ToCharArray()
Dim data As Byte() = New Byte(0) {}
Dim crypto As New RNGCryptoServiceProvider()
crypto.GetNonZeroBytes(data)
data = New Byte(maxSize - 1) {}
crypto.GetNonZeroBytes(data)
Dim result As New StringBuilder(maxSize)
For Each b As Byte In data
result.Append(chars(b Mod (chars.Length)))
Next
Return result.ToString()
End Function
Private Sub txtCash_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtDinheiro.TextChanged
txtTroco.Text = Format(Val(txtDinheiro.Text) - Val(txtTotal.Text), "#,##0.00")
End Sub
Private Sub BtnConcluido_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnConcluido.Click
If Val(txtTotal.Text) > Val(txtDinheiro.Text) Then
MessageBox.Show("Informe um valor maior ou igual ao valor total.", "Valor inválido", MessageBoxButtons.OK, MessageBoxIcon.Error)
Else
Dim prodname As String = ""
'If frmMenu.prod.StartsWith(",") = True Then
' prodname = frmMenu.prod.Remove(0, 1)
'End If
For i = 0 To Me.LstOrder.Items.Count - 1
prodname = prodname & "," & LstOrder.Items(i).ToString.Replace("& vbcrlf", "")
Next i
If prodname.StartsWith(",") = True Then
prodname = prodname.Remove(0, 1)
End If
Dim trpath As String = Application.StartupPath & "\Record\Registro.txt"
File.AppendAllText(trpath, ReceitaNo.Text & " | " & Format(Date.Now, "dd/MM/yyyy") & " | " & prodname.Trim & " | " & txtTotal.Text & " | " & Format(Val(txtDinheiro.Text), "#,###.00") & " | " & txtTroco.Text & vbCrLf)
With frmReceipt
For i = 0 To Me.LstOrder.Items.Count - 1
.LstOrder.Items.Add(LstOrder.Items(i))
Next i
.ReceiptNo.Text = Me.ReceitaNo.Text
.lblTotal.Text = Me.txtTotal.Text
.lblCash.Text = Me.txtDinheiro.Text
.lblChange.Text = Me.txtTroco.Text
.ShowDialog()
End With
prodname = ""
btnClose_Click(sender, e)
frmMenu.BtnClear_Click(sender, e)
frmMenu.dtgRecord.Rows.Clear()
frmMenu.Filter_Record()
End If
End Sub
Private Sub frmPayment_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ReceitaNo.Text = "BURGER-" & GetUniqueKey(6)
End Sub
Private Sub LstOrder_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LstOrder.SelectedIndexChanged
End Sub
Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click
End Sub
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
End Sub
Private Sub txtTotal_TextChanged(sender As Object, e As EventArgs) Handles txtTotal.TextChanged
End Sub
End Class
Link para o comentário
Compartilhar em outros sites
5 respostass a esta questão
Posts Recomendados
Participe da discussão
Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.