Doug.Vulcano
23-11-2010 18:42:07
Pessoal precisando que meu banco de dados faça algumas contas simples porem nãoe sta dando certo vou colocar o codigo aqui se algume souber me ajudar eu agradeço,
oque esta dando errado é o CapRate, não sei pq!!
ps: (estou usando o modelo V2) so inclui algumas contas na sub SalvaRegistro
Private Sub SalvaRegistro(ByVal id As Long, ByVal indice As Long)
Dim PrecoPedido As Double
Dim PrecoMetro As Double
Dim Aluguel As Double
Dim AluguelMetro As Double
Dim CapRate As Double
If Me.TextBox_PrecoPedido = "" Then
PrecoPedido = Me.TextBox_Area.Value * Me.TextBox_PrecoMetro.Value
wsCadastro.Cells(indice, colPrecoPedido).Value = PrecoPedido
Else
wsCadastro.Cells(indice, colPrecoPedido).Value = Me.TextBox_PrecoPedido
End If
If Me.TextBox_PrecoMetro = "" Then
PrecoMetro = Me.TextBox_PrecoPedido.Value / Me.TextBox_Area
wsCadastro.Cells(indice, colPrecoMetro).Value = PrecoMetro
Else
wsCadastro.Cells(indice, colPrecoMetro).Value = Me.TextBox_PrecoMetro.Value
End If
If Me.TextBox_Aluguel = "" Then
Aluguel = Me.TextBox_AluguelMetro.Value * Me.TextBox_Area.Value
Else
wsCadastro.Cells(indice, colAluguel).Value = Me.TextBox_Aluguel.Value
End If
If Me.TextBox_AluguelMetro = "" Then
AluguelMetro = Me.TextBox_Aluguel.Value / Me.TextBox_Area.Value
Else
wsCadastro.Cells(indice, colAluguelMetro).Value = Me.TextBox_AluguelMetro.Value
End If
Me.TextBox_PrecoPedido.Value = PrecoPedido
Me.TextBox_Aluguel.Value = Aluguel
If Me.TextBox_CapRate = "" Then
CapRate = Aluguel * 12 / PrecoPedido
wsCadastro.Cells(indiceRegistro, colCapRate).Value = CapRate
Else
wsCadastro.Cells(indiceRegistro, colCapRate).Value = Me.TextBox_CapRate.Value
Me.TextBox_CapRate.Value = CapRate
End If
With wsCadastro
.Cells(indice, colCodigo).Value = id
.Cells(indice, colData).Value = Me.TextBox_Data.Text
.Cells(indice, colNome).Value = Me.TextBox_Nome.Text
.Cells(indice, colBairro).Value = Me.TextBox_Bairro.Text
.Cells(indice, colEndereco).Value = Me.TextBox_Endereco.Text
.Cells(indice, colComplemento).Value = Me.TextBox_Complemento.Text
.Cells(indice, colCidade).Value = Me.TextBox_Cidade.Text
.Cells(indice, colEstado).Value = Me.ComboBox_Estado.Text
.Cells(indice, colArea).Value = Me.TextBox_Area.Value
'.Cells(indice, colPrecoPedido).Value = PrecoPedido
'.Cells(indice, colPrecoMetro).Value = Me.TextBox_PrecoMetro.Value
'.Cells(indiceRegistro, colCapRate).Value = Me.TextBox_CapRate.Value
.Cells(indice, colCorretora).Value = Me.TextBox_Corretora.Text
.Cells(indice, colContato).Value = Me.TextBox_Contato.Text
.Cells(indice, colStatus).Value = Me.TextBox_Status.Text
.Cells(indice, colClassificacao).Value = Me.TextBox_Classificacao.Text
.Cells(indiceRegistro, colLink).Value = Me.TextBox_Link.Text
End With
Call AtualizaRegistroCorrente
End Sub
oque esta dando errado é o CapRate, não sei pq!!
ps: (estou usando o modelo V2) so inclui algumas contas na sub SalvaRegistro
Private Sub SalvaRegistro(ByVal id As Long, ByVal indice As Long)
Dim PrecoPedido As Double
Dim PrecoMetro As Double
Dim Aluguel As Double
Dim AluguelMetro As Double
Dim CapRate As Double
If Me.TextBox_PrecoPedido = "" Then
PrecoPedido = Me.TextBox_Area.Value * Me.TextBox_PrecoMetro.Value
wsCadastro.Cells(indice, colPrecoPedido).Value = PrecoPedido
Else
wsCadastro.Cells(indice, colPrecoPedido).Value = Me.TextBox_PrecoPedido
End If
If Me.TextBox_PrecoMetro = "" Then
PrecoMetro = Me.TextBox_PrecoPedido.Value / Me.TextBox_Area
wsCadastro.Cells(indice, colPrecoMetro).Value = PrecoMetro
Else
wsCadastro.Cells(indice, colPrecoMetro).Value = Me.TextBox_PrecoMetro.Value
End If
If Me.TextBox_Aluguel = "" Then
Aluguel = Me.TextBox_AluguelMetro.Value * Me.TextBox_Area.Value
Else
wsCadastro.Cells(indice, colAluguel).Value = Me.TextBox_Aluguel.Value
End If
If Me.TextBox_AluguelMetro = "" Then
AluguelMetro = Me.TextBox_Aluguel.Value / Me.TextBox_Area.Value
Else
wsCadastro.Cells(indice, colAluguelMetro).Value = Me.TextBox_AluguelMetro.Value
End If
Me.TextBox_PrecoPedido.Value = PrecoPedido
Me.TextBox_Aluguel.Value = Aluguel
If Me.TextBox_CapRate = "" Then
CapRate = Aluguel * 12 / PrecoPedido
wsCadastro.Cells(indiceRegistro, colCapRate).Value = CapRate
Else
wsCadastro.Cells(indiceRegistro, colCapRate).Value = Me.TextBox_CapRate.Value
Me.TextBox_CapRate.Value = CapRate
End If
With wsCadastro
.Cells(indice, colCodigo).Value = id
.Cells(indice, colData).Value = Me.TextBox_Data.Text
.Cells(indice, colNome).Value = Me.TextBox_Nome.Text
.Cells(indice, colBairro).Value = Me.TextBox_Bairro.Text
.Cells(indice, colEndereco).Value = Me.TextBox_Endereco.Text
.Cells(indice, colComplemento).Value = Me.TextBox_Complemento.Text
.Cells(indice, colCidade).Value = Me.TextBox_Cidade.Text
.Cells(indice, colEstado).Value = Me.ComboBox_Estado.Text
.Cells(indice, colArea).Value = Me.TextBox_Area.Value
'.Cells(indice, colPrecoPedido).Value = PrecoPedido
'.Cells(indice, colPrecoMetro).Value = Me.TextBox_PrecoMetro.Value
'.Cells(indiceRegistro, colCapRate).Value = Me.TextBox_CapRate.Value
.Cells(indice, colCorretora).Value = Me.TextBox_Corretora.Text
.Cells(indice, colContato).Value = Me.TextBox_Contato.Text
.Cells(indice, colStatus).Value = Me.TextBox_Status.Text
.Cells(indice, colClassificacao).Value = Me.TextBox_Classificacao.Text
.Cells(indiceRegistro, colLink).Value = Me.TextBox_Link.Text
End With
Call AtualizaRegistroCorrente
End Sub