나는 세 개의 텍스트 상자를 가지고 있고이 같은 자신의 가치를 얻을 :VBA에서 통화를 이중으로 변환하는 방법은 무엇입니까?
Dim X, Y, W As Double
X = DLookup("Summ", "tblPlatej", "ID= " & Form_frmPlatej!ID)
Y = DLookup("Deposit_before", "tblPlatej", "ID= " & Form_frmPlatej!ID)
W = DLookup("Monthly_payment", "tblPlatej", "ID= " & Form_frmPlatej!ID)
을하지만이
Form_frmPlatej.Deposit_before = X - W + Y
같은 텍스트 상자의 값을 변경할 때 나는 형식 불일치 오류가 발생합니다. 모든 텍스트 상자는 통화입니다. 새 레코드를 어떻게 계산하고 "Deposit_before"텍스트 상자에 그 번호를 입력합니까?
Summ, Deposit_before, Monthly_payment는 테이블의 통화 데이터 유형입니다. Deposit_before은 대부분 음수입니다.
여기에 버튼 내 전체 코드는
Private Sub Command13_Click()
a1 = DLookup("Inhabitant", "tblClient", "ID = " & Form_frmMain!ID)
B1 = DLookup("PriceTBO", "tblPrice")
c1 = DLookup("Republican", "tblClient", "ID = " & Form_frmMain!ID)
d1 = DLookup("Regional", "tblClient", "ID = " & Form_frmMain!ID)
e1 = DLookup("Local", "tblClient", "ID = " & Form_frmMain!ID)
A = DLookup("IDP", "tblPlatej", "ID= " & Form_frmPlatej!ID)
B = DLookup("Type_of_payment", "tblPlatej", "ID= " & Form_frmPlatej!ID)
C = DLookup("Year", "tblPlatej", "ID= " & Form_frmPlatej!ID)
D = DLookup("Month", "tblPlatej", "ID= " & Form_frmPlatej!ID)
Y = DLookup("Deposit_before", "tblPlatej", "ID= " & Form_frmPlatej!ID) // Problem here
W = DLookup("Monthly_payment", "tblPlatej", "ID= " & Form_frmPlatej!ID) //Problem here
X = DLookup("Summ", "tblPlatej", "ID= " & Form_frmPlatej!ID)
i = Form_frmPlatej.Month.ListIndex
j = Form_frmPlatej.Year.ListIndex
den = DLookup("Date", "tblPlatej", "IDP = " & Form_frmPlatej!IDP)
If X <> " " Then
With Me.Recordset
If Me.Recordset.BOF = False And Me.Recordset.EOF = False Then
.MoveFirst
End If
.AddNew
.Edit
Form_frmPlatej.Deposit_before = X - W + Y //Problem here
Form_frmPlatej.IDP = A + 1
Form_frmPlatej.Type_of_payment = B
If i = 11 Then
Form_frmPlatej.Year = Year.ItemData(j + 1)
i = -1
Else
Form_frmPlatej.Year = Year.ItemData(j)
End If
Form_frmPlatej.Month = Month.ItemData(i + 1)
Form_frmPlatej.Date = DateAdd("m", 1, den)
If c1 <> 0 Then
Form_frmPlatej.Monthly_payment = (a1 * B1) - (c1 * (a1 * B1))/100
ElseIf d1 <> 0 Then
Form_frmPlatej.Monthly_payment = (a1 * B1) - (d1 * (a1 * B1))/100
ElseIf e1 <> 0 Then
Form_frmPlatej.Monthly_payment = (a1 * B1) - (e1 * (a1 * B1))/100
Else
Form_frmPlatej.Monthly_payment = a1 * B1
End If
.Update
End With
Else
MsgBox ("Please enter number")
End If
End Sub
나는 완전히 혼란 스러워요 클릭합니다.
난 당신이 통화에서 두 배로 변환하고자하는 이유에 대해 궁금합니다 :
또한 내가 문구의 일부를 재사용있는 광산의 이전 대답을 참조하십시오? 통화 유형을 가지고있을 때 통화 유형을 사용하지 않으시겠습니까? http://stackoverflow.com/questions/3730019/why-not-use-double-or-float-to-represent-currency – Fionnuala