Página 1 de 1

Contador de moedas e notas

Enviado: 21 Out 2017 às 07:50
por pasedo
Bom dia pessoal, alguém sabe com fazer decompor notas e moedas no formulario entrando com um valor no textbox em amareo e ele mostrar a quantidade de notas e moedas nas outras textbox. grato

Re: Contador de moedas e notas

Enviado: 21 Out 2017 às 08:18
por Reinaldo
Segue dois modelos na planilha que talvez lhe de algo.

Contador de moedas e notas

Enviado: 21 Out 2017 às 09:31
por pasedo
Reinaldo, obrigado pela ajuda, consegui fazer o que queria em partes, as notas eu consegui ,só não estou conseguindo com as moedas , e também com problemas se o valor for grande ele não faz a leitura do valor digitado, segue o arquivo ai com as alterações que eu consegui fazer no formulario, poderia me dar uma ajuda?

Re: Contador de moedas e notas

Enviado: 22 Out 2017 às 10:25
por Reinaldo
Experimente:
Código: Selecionar todos
Private Sub TextBox13_Change()
Dim ProdPrice As Currency
Dim Nota100 As Double
Dim Nota50 As Double
Dim Nota20 As Double
Dim Nota10 As Double
Dim Nota5 As Double
Dim Nota2 As Double
Dim Moeda100 As Double
Dim Moeda050 As Double
Dim Moeda010 As Double
Dim Moeda025 As Double
Dim Moeda005 As Double
Dim Moeda001 As Double
Const N100 = 100#: Const C100 = 1#
Const N050 = 50#: Const C050 = 0.5
Const N020 = 20#: Const C025 = 0.25
Const N010 = 10#: Const C010 = 0.1
Const N005 = 5#: Const C005 = 0.05
Const N002 = 2#: Const C001 = 0.01
'On Error Resume Next
If TextBox13.Text <> "" Then
    ProdPrice = CDbl(TextBox13.Text)
Else
    MsgBox "Informe o valor"
End If
 
If ProdPrice / N100 > 0 Then
    Nota100 = Fix(ProdPrice / N100)
    ProdPrice = Round(ProdPrice - (Nota100 * N100), 2)
End If
If ProdPrice / N050 > 0 Then
    Nota50 = Fix(ProdPrice / N050)
    ProdPrice = Round(ProdPrice - (Nota50 * N050), 2)
End If
If ProdPrice / N020 > 0 Then
    Nota20 = Fix(ProdPrice / N020)
    ProdPrice = Round(ProdPrice - (Nota20 * N020), 2)
End If
If ProdPrice / N010 > 0 Then
    Nota10 = Fix(ProdPrice / N010)
    ProdPrice = Round(ProdPrice - (Nota10 * N010), 2)
End If
If ProdPrice / N005 > 0 Then
    Nota5 = Fix(ProdPrice / N005)
    ProdPrice = Round(ProdPrice - (Nota5 * N005), 2)
End If
If ProdPrice / N002 > 0 Then
    Nota2 = Fix(ProdPrice / N002)
    ProdPrice = Round(ProdPrice - (Nota2 * N002), 2)
End If
If ProdPrice / C100 > 0 Then
    Moeda100 = Fix(ProdPrice / C100)
    ProdPrice = Round(ProdPrice - (Moeda100 * C100), 2)
End If
If ProdPrice / C050 > 0 Then
    Moeda050 = Fix(ProdPrice / C050)
    ProdPrice = Round(ProdPrice - (Moeda050 * C050), 2)
End If
If ProdPrice / C025 > 0 Then
    Moeda025 = Fix(ProdPrice / C025)
    ProdPrice = Round(ProdPrice - (Moeda025 * C025), 2)
End If
If ProdPrice / C010 > 0 Then
    Moeda010 = Fix(ProdPrice / C010)
    ProdPrice = Round(ProdPrice - (Moeda010 * C010), 2)
End If
If ProdPrice / C005 > 0 Then
    Moeda005 = Fix(ProdPrice / C005)
    ProdPrice = Round(ProdPrice - (Moeda005 * C005), 2)
End If
If ProdPrice / C001 > 0 Then
    Moeda001 = Round(Fix(ProdPrice * 10 / C001 * 10) / 100, 0)
End If

     

TextBox1.Text = Nota100
TextBox2.Text = Nota50
TextBox3.Text = Nota20
TextBox4.Text = Nota10
TextBox5.Text = Nota5
TextBox6.Text = Nota2
TextBox7.Text = Moeda100
TextBox8.Text = Moeda050
TextBox9.Text = Moeda025
TextBox10.Text = Moeda010
TextBox11.Text = Moeda005
TextBox12.Text = Moeda001
End Sub

Contador de moedas e notas

Enviado: 22 Out 2017 às 13:52
por pasedo
Obrigado mais uma vez Reinaldo, funcionou perfeitamente