Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

傳回代表 RGB 色彩值的 Long。

語法

RGB ( 紅、綠、藍 )

RGB 函數語法具有下列自變數:

引數

描述

紅色

必要。 Variant (Integer) 。 範圍 0-255 的數位,含內含,代表色彩的紅色元件。

綠色

必要。 Variant (Integer) 。 範圍 0-255 的數位,含,代表色彩的綠色元件。

藍色

必要。 Variant (Integer) 。 範圍 0-255 的數位,含內含,代表色彩的藍色元件。


註解

接受色彩規格的應用程式方法和屬性預期規格會是代表 RGB 色彩值的數位。 RGB 色彩值指定紅色、綠色和藍色的相對濃度,以致於顯示特定色彩。

若任 引數 至 RGB 超過 255 的值為 255。

下表列出一些標準色彩,以及包含的紅色、綠色和藍色值:

色彩

紅色值

綠色值

藍色值

黑色

0

0

0

藍色

0

0

255

綠色

0

255

0

青色

0

255

255

紅色

255

0

0

品紅

255

0

255

黃色

255

255

0

白色

255

255

255


此函數傳回的 RGB 色彩值與 Macintosh 作業系統所使用的值不相容。 它們可能會在Macintosh的 Microsoft 應用程式內使用,但不應在直接將色彩變更傳達至Macintosh作業系統時使用。

範例

附註: 下列範例示範如何在 Visual Basic for Applications (VBA) 模組中使用此函數。 如需使用 VBA 的詳細資訊,請在 [搜尋] 旁的下拉式清單中選取 [開發人員參考],並在 [搜尋] 方塊中輸入一個或多個字詞。

此範例示範如何使用 RGB 函數傳回代表 RGB 色彩值的整數。 它用於接受色彩規格的應用程式方法和屬性。 物件 MyObject 及其屬性僅供圖例使用。 如果 MyObject 不存在,或是它沒有 Color 屬性,則會發生錯誤。

Dim RED, I, RGBValue, MyObject
' Return the value for Red.
Red = RGB(255, 0, 0)
' Initialize offset.
I = 75
RGBValue = RGB(I, 64 + I, 128 + I)
' Same as RGB(75, 139, 203).
' Set the Color property of MyObject to Red.
MyObject.Color = RGB(255, 0, 0)

Need more help?

Want more options?

探索訂閱權益、瀏覽訓練課程、瞭解如何保護您的裝置等等。

社群可協助您詢問並回答問題、提供意見反應,以及聆聽來自具有豐富知識的專家意見。

Was this information helpful?

How satisfied are you with the translation quality?
What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×