|
可以用下面的程序
Function PIsLoaded(ByVal strFormName As String) As Integer
' Returns True if the specified form is open in Form view or Datasheet view.
'DoCmd.DoMenuItem acFormBar, acToolMenu, acSaveRecord, , acMenuVer70
Const conObjStateClosed = 0
Const conDesignView = 0
If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> conObjStateClosed Then
If Forms(strFormName).CurrentView <> conDesignView Then
PIsLoaded = True
End If
End If
End Function
Private Function cch(n1) As String
Select Case n1
Case 0: cch = "零"
Case 1: cch = "壹"
Case 2: cch = "贰"
Case 3: cch = "叁"
Case 4: cch = "肆"
Case 5: cch = "伍"
Case 6: cch = "陆"
Case 7: cch = "柒"
Case 8: cch = "捌"
Case 9: cch = "玖"
End Select
End Function
'名称: ChMoney
' 得到数字 N1 的汉字大写
' 最大为 千亿
' O 返回 ""
Public Function ChMoney(n1) As String
Dim tMoney As String
Dim lMoney As String
Dim tn '小数位置
Dim s1 As String '临时STRING 小数部分
Dim s2 As String '1000 以内
Dim s3 As String '10000
Dim s4 As String
Dim s5 As String
Dim s As String
If n1 = 0 Then
ChMoney = " "
Exit Function
End If
If n1 < 0 Then
ChMoney = "负" + ChMoney(Abs(n1))
Exit Function
End If
tMoney = Trim(Str(n1))
tn = InStr(tMoney, ".") '小数位置
s1 = ""
If tn = 0 Then '角分为零,
s1 = "整"
End If
If tn <> 0 Then
ST1 = Right(tMoney, Len(tMoney) - tn) '小数
If ST1 <> "" Then
T1 = Left(ST1, 1)
ST1 = Right(ST1, Len(ST1) - 1)
If T1 <> "0" And ST1 <> "" Then
s1 = s1 + cch(Val(T1)) + "角"
End If
If T1 <> "0" And ST1 = "" Then '角位不为零,分位为零
s1 = s1 + cch(Val(T1)) + "角整"
End If
If T1 = "0" And ST1 <> "" Then '角位为零时
s1 = s1 + cch(Val(T1))
End If
If ST1 <> "" Then
T1 = Left(ST1, 1)
s1 = s1 + cch(Val(T1)) + "分"
End If
End If
'=============================================================================
'以上是小数的转换
ST1 = Left(tMoney, tn - 1)
Else
ST1 = tMoney
End If
s2 = ""
If ST1 <> "" Then
T1 = Right(ST1, 1)
ST1 = Left(ST1, Len(ST1) - 1)
s2 = cch(Val(T1)) + s2
End If
'元
If ST1 <> "" Then
T1 = Right(ST1, 1)
ST1 = Left(ST1, Len(ST1) - 1)
If T1 <> "0" Then
s2 = cch(Val(T1)) + "拾" + s2
Else
If Left(s2, 1) <> "零" Then s2 = "零" + s2
End If
End If
'十
If ST1 <> "" Then
T1 = Right(ST1, 1)
ST1 = Left(ST1, Len(ST1) - 1)
If T1 <> "0" Then
s2 = cch(Val(T1)) + "佰" + s2
Else
If Left(s2, 1) <> "零" Then s2 = "零" + s2
End If
End If
'百
If ST1 <> "" Then
T1 = Right(ST1, 1)
ST1 = Left(ST1, Len(ST1) - 1)
If T1 <> "0" Then
s2 = cch(Val(T1)) + "仟" + s2
Else
If Left(s2, 1) <> "零" Then s2 = "零" + s2
End If
End If
'千
'============================================================================
s3 = ""
If ST1 <> "" Then
T1 = Right(ST1, 1)
ST1 = Left(ST1, Len(ST1) - 1)
s3 = cch(Val(T1 |
|