【金額轉(zhuǎn)換成中文大寫】【進(jìn)入窗體設(shè)計視圖】【鏈接外部數(shù)據(jù)庫只能查看數(shù)據(jù)】
金額轉(zhuǎn)換成中文大寫
Private Sub Command轉(zhuǎn)換_Click()
If Me.金額數(shù)字 <> "" Then
? ? If IsNumeric(Me.金額數(shù)字) = True Then
? ? ? ? Me.金額大寫 = rmb(Me.金額數(shù)字)
? ? Else
? ? MsgBox "請輸入數(shù)字"
? ? Exit Sub
? ? End If
End If
End Sub
Public Function rmb(s As Currency) As String? ? '人民幣轉(zhuǎn)大寫
Dim s1, s2, l, x
? ? s1 = LTrim(CStr(Abs(s)))
? ? l = Len(s1)
? ? Select Case l - InStrRev(s1, ".")
? ? '雙引號內(nèi)是小數(shù)點
? ? ? ?Case l
? ? ? ? ?s2 = s1 + ".00"
? ? ? ?Case 1
? ? ? ? ?s2 = s1 + "0"
? ? ? ?Case 2
? ? ? ? ?s2 = s1
? ? End Select
? ? l = Len(s2)
? ? Dim dx, c1, c2
? ? dx = ""
? ? c1 = "零壹貳叁肆伍陸柒捌玖"
? ? c2 = "分角 元拾佰仟萬拾佰仟億拾佰"
? ? '角和元之間留一個空格
? ? ?Do While l >= 1
? ? ?x = Mid(s2, Len(s2) - l + 1, 1)
? ? ?
? ??
? ? If x <> "." Then
? ? dx = dx + Mid(c1, Val(x) + 1, 1) + Trim(Mid(c2, (l - 1) + 1, 1))
? ? End If
? ? ?l = l - 1
? ? ?Loop
? ? ?rmb = dx + "整"
End Function
進(jìn)入窗體設(shè)計視圖
Private Sub Command打開_Click()
If Me.窗體列表 <> "" Then
DoCmd.Minimize
DoCmd.OpenForm Me.窗體列表, acDesign
End If
End Sub
Private Sub Command設(shè)計視圖_Click()
DoCmd.OpenForm "演示窗體", acDesign
End Sub
鏈接外部數(shù)據(jù)庫只能查看數(shù)據(jù)
Private Sub Form_Load()
Dim df_conn As New ADODB.Connection
'------------------------------------------------------------------
With df_conn
? ? .Provider = "microsoft.ace.oledb.12.0;Jet OLEDB:Database Password='abc123'"
? ? .ConnectionString = CurrentProject.Path & "\報價表.accdb"
? ? .Open
End With
'------------------------------------------------------------------
Dim dflink_rs As New ADODB.Recordset
dflink_rs.CursorLocation = adUseClient
Dim dflink_sql As String
dflink_sql = "SELECT * FROM 商品報價表"
dflink_rs.Open dflink_sql, df_conn, adOpenDynamic, adLockOptimistic
Set Me.Recordset = dflink_rs
dflink_rs.Close
Set dflink_rs = Nothing
df_conn.Close
Set df_conn = Nothing
Exit Sub
數(shù)據(jù)獲取失敗:
MsgBox Err.Description
End Sub