Private Sub CmdValid_Click()
On Error GoTo ErrValid:
Dim LngExec As Long
Dim varCie
Dim ret As VbMsgBoxResult
Dim StrSql
Dim DblBalance
If Me.SF.Form.Dirty Then
Me.SF.Form.Refresh
End If
DblBalance = aaRound(aaRound(Me.SF.Form.TxtCreditTotal.Value, 2) - aaRound(Me.SF.Form.TxtDebitTotal.Value, 2), 2)
If DblBalance <> 0 Then
MsgBox "Credit must be equal to credit. Press Delete if you want to delete this journal entry, or enter the appropriate values", vbCritical, "Validation refused"
Else
'---- We have to create the two record into the General ledger detail
StrSql = "EXEC SpValidGenLedDet " & str(Me.GLHCode)
LngExec = aaExecuteSP(StrSql)
If LngExec = 0 Then
DoCmd.SetWarnings (False)
StrSql = "EXEC SpDelGenLedDetTmp " & str(Me.GLHCode)
LngExec = aaExecuteSP(StrSql)
DoCmd.SetWarnings (True)
ret = MsgBox("This entry is successfully validated. Do you want to create another entry ?" & Chr(13) & Chr(10) & "click YES to add a new one , NO to close this form", vbInformation + vbYesNo, "validation accepted")
If ret = vbYes Then
varCie = Me.CboGlHInternalCie
DoCmd.GoToRecord , , acNewRec
If Not IsNull(varCie) Then
Me.GlHInternalCie = CLng(varCie)
End If
Else
DoCmd.Close acForm, Me.Name
End If
Else
MsgBox "There was an error while Writing the accounting lines into the General ledger, retry to validate or press delete to cancel the transaction"
End If
End If
finValid:
Exit Sub
ErrValid:
MsgBox "Error during validation", vbCritical, "Error"
Resume finValid
End Sub
我有一个 VBA 代码,我需要将其转换为上面给出的 c# 但是我无法理解为什么某些事情正在完成或发生
例如,上面的代码在Private Sub CmdValid_Click()
此按钮的属性下,单击前景色设置为 -2147483630 的值。当我执行代码并检查断点时,我在 LngExec 中得到值 -2147483630。
然而,SpDelGenLedDetTmp 过程只是一个带有 where 子句的简单删除过程
**
/****** Object: StoredProcedure [dbo].[SpDelGenLedTmp] Script Date: 10/28/2012 12:27:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
ALTER PROCEDURE [dbo].[SpDelGenLedTmp]
(@GHDHeader_1 [int])
AS DELETE [ABOUSQL].[dbo].[TblGenLedDetTmp]
WHERE
( [GHDHeader] = @GHDHeader_1)
**
Function aaExecuteSP(StrSql) As Long
On Error GoTo ErrGetData
Dim cnn As ADODB.Connection
Dim isok
Set cnn = aaDbConnect()
cnn.Execute (StrSql)
aaExecuteSP = 0
FinGetData:
Exit Function
ErrGetData:
If Err.Number <> 0 Then
aaExecuteSP = Err.Number
End If
Resume FinGetData
End Function
任何帮助将不胜感激我对 VBA 很陌生
谢谢并恭祝安康