Este fórum está sendo desativado

Depois de 9 anos, este fórum será desativado. Mas calma.... estamos migrando para uma comunidade no DISCORD. Junte-se a nós.

ENTRAR PARA DISCORD

Tópicos relacionados a códigos VBA, gravação de macros, etc.
  • Avatar do usuário
  • Avatar do usuário
Avatar do usuário
Por pasedo
Posts Avatar
#27634
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
Você não está autorizado a ver ou baixar esse anexo.
Avatar do usuário
Por Reinaldo
Avatar
#27635
Segue dois modelos na planilha que talvez lhe de algo.
Você não está autorizado a ver ou baixar esse anexo.
Avatar do usuário
Por pasedo
Posts Avatar
#27636
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?
Você não está autorizado a ver ou baixar esse anexo.
Avatar do usuário
Por Reinaldo
Avatar
#27645
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
long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]

Estamos migrando para uma comunidade no Discord