Edu
05-08-2011 14:15:28
Bom dia eu tenho um form onde tenho algums text box eum botao salvar, criei a rotina que verifica se os valores digitados em dois text box(vlrcomp e vlrvend), porem ele ta me dando um erro ele salva os dados mesmo se o valor do meu txt box vlr vend for menor que meu txt box vlr comp, gostaria de saber se vc poderiam me ajudar come esse problema.
Segue o codigo abaixo
Private Sub btn_salvar_Click()
if txt_vlrvend.value < txt_vlrcomp.value then
msgbox "Valor de venda menor que o valor de compra",vbokonly + vbcritical ,"Eduardo Santos"
exit sub
end if
If txt_vlrvend.Value = txt_vlrcomp.Value Then
MsgBox "Valor de compra igual ao valor de venda", vbOKOnly + vbCritical, "Eduardo Santos"
Exit Sub
End If
If txt_nome.Value = "" Or txt_qtd.Value = "" Or txt_vlrvend.Value = "" Then
MsgBox "Informe os dados", vbOKOnly + vbCritical, "Eduardo Santos"
txt_nome.SetFocus
Exit Sub
End If
If ComboBox_pesquisa.ListIndex = -1 Then
DadosLinha = Dados.UsedRange.Rows.Count + 1
Dados.Range("CodCalc").Value = CadastroCodigo
End If
atualizaplan
MsgBox "Operacao efetuada com sucesso"
restauracontroles
atualizacomboboxpesquisa
CadastroCodigo = Dados.Range("CodCalc").Value + 1
txt_codigo.Value = CadastroCodigo
End Sub
Segue o codigo abaixo
Private Sub btn_salvar_Click()
if txt_vlrvend.value < txt_vlrcomp.value then
msgbox "Valor de venda menor que o valor de compra",vbokonly + vbcritical ,"Eduardo Santos"
exit sub
end if
If txt_vlrvend.Value = txt_vlrcomp.Value Then
MsgBox "Valor de compra igual ao valor de venda", vbOKOnly + vbCritical, "Eduardo Santos"
Exit Sub
End If
If txt_nome.Value = "" Or txt_qtd.Value = "" Or txt_vlrvend.Value = "" Then
MsgBox "Informe os dados", vbOKOnly + vbCritical, "Eduardo Santos"
txt_nome.SetFocus
Exit Sub
End If
If ComboBox_pesquisa.ListIndex = -1 Then
DadosLinha = Dados.UsedRange.Rows.Count + 1
Dados.Range("CodCalc").Value = CadastroCodigo
End If
atualizaplan
MsgBox "Operacao efetuada com sucesso"
restauracontroles
atualizacomboboxpesquisa
CadastroCodigo = Dados.Range("CodCalc").Value + 1
txt_codigo.Value = CadastroCodigo
End Sub