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.

適用對象

CheckBox 物件

OptionButton 物件

ToggleButton 物件

選項群組中的每個控制項都有您可以用來設定 OptionValue 屬性的數值。 讀/寫長整數

expression.OptionValue

運算式 必要。 傳回 [套用至] 清單中其中一個對象的表達式。

備註

選取控制項時,數字會指派給選項群組。 如果選項群組與欄位繫結,則所選控制項值的 OptionValue 屬性會儲存在欄位中。

例如,此 Region 選項群組與資料表中的 Region 欄位繫結。 Europe 按鈕已將 OptionValue 屬性設為 1、Asia按鈕設為 2,Africa 按鈕設為 3。 當選取其中一個按鈕時,Region 選項群組值將會與所選控制項的 OptionValue 屬性設定相同。 在此情況下,由於 Region 選項群組繫結至 Region 欄位,因此這個資料表中的欄位值也等於 2。

附註:  OptionValue 屬性僅適用於選項群組中的核取方塊、選項按鈕和切換按鈕控制項。

您可以使用控制項的屬性工作表、巨集或 Visual Basic for Applications (VBA) 程式碼來設定 OptionValue 屬性。

除非您自行變更 OptionValue 屬性,不然您在選項群組中放的第一個控制項值會是 1,第二個控制項值則會是 2,以此類推。

只有當控制項置於選項群組控制項內時,才能使用 OptionValue 屬性。 當核取方塊、切換按鈕或選項按鈕未放在選項群組中時,控制項就不會有 OptionValue 屬性。 不過,每個這類控制項都會有 ControlSource 屬性,且每個控制項的值都會是 True (已選取時) 或 False (未選取時)。

範例

以下範例會在表單開啟時,設定「Ship Method Group」選項群組中三個選項按鈕的 OptionValue 屬性。 選取選項群組中的選項按鈕時,就會出現訊息指出送貨者的指定識別碼。

Private Sub Form_Open(Cancel As Integer)
Me.Controls("ABC Couriers").OptionValue = 15876
Me.Controls("Speedy Delivery").OptionValue = 742
Me.Controls("Lightning Express").OptionValue = 1256
End Sub
Private Sub Ship_Method_Group_Click()
MsgBox "The ID for the selected shipper is " & _
Me.Controls("Ship Method Group").Value
End Sub

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!

×