Visual Basic 6.0 中的 OptionButton 控件在 Visual Basic 2005 中由 Windows 窗體
在 Visual Basic 6.0 中,OptionButton 控件的 Click 事件僅當(dāng)其 Value 屬性更改為 True 時(shí)才引發(fā)。
在 Visual Basic 2005 中,RadioButton 控件的
此外,還有許多適用于所有控件的概念差異,包括數(shù)據(jù)綁定、字體處理、拖放功能、幫助支持等方面的差異。有關(guān)更多信息,請(qǐng)參見適用于 Visual Basic 6.0 用戶的 Windows 窗體概念。
下面的示例演示 Visual Basic 6.0 和 Visual Basic 2005 在編碼方法上的不同之處。
下面的代碼演示如何在運(yùn)行時(shí)從包含 OptionButton 和 RadioButton 控件的組中選擇這兩個(gè)控件之一。
![]() | |
---|---|
' Visual Basic 6.0 If Option1.Value = True Then Option2.Value = True Else Option1.Value = True End If |
Visual Basic | ![]() |
---|---|
' Visual Basic 2005 If RadioButton1.Checked = True Then RadioButton2.Checked = True Else RadioButton1.Checked = True End If |
下面的代碼演示如何處理 OptionButton 控件的 Click 事件,以及如何處理 RadioButton 控件的 CheckedChanged 事件。
![]() | |
---|---|
' Visual Basic 6.0 ' The Click event is only fired when the Value is True Private Sub Option1_Click() MsgBox "Option1 was clicked" End Sub Private Sub Option2_Click() MsgBox "Option2 was clicked" End Sub |
Visual Basic | ![]() |
---|---|
' Visual Basic 2005 ' The CheckChanged event fires each time the RadioButton's Checked ' value changes to either True or False. Private Sub RadioButton1_CheckedChanged(ByVal sender As Object, ByVal _ e As System.EventArgs) Handles RadioButton1.CheckedChanged, _ RadioButton2.CheckedChanged ' Only execute if the Checked value is True. If sender.Checked = True Then MsgBox(sender.Name & " was clicked") End If End Sub |
下面幾個(gè)表列出了 Visual Basic 6.0 中的屬性、方法和事件及它們的 Visual Basic 2005 等效項(xiàng)。具有相同的名稱和行為的屬性、方法和事件未予列出。如果適用,常數(shù)在屬性或方法的下面縮進(jìn)。除非另外說明,否則所有 Visual Basic 2005 枚舉都映射到
此表提供相關(guān)主題的鏈接,這些主題對(duì)行為之間的差異進(jìn)行說明。如果 Visual Basic 2005 中沒有直接等效項(xiàng),則提供指向介紹替換項(xiàng)的主題的鏈接。
Visual Basic 6.0 | Visual Basic 2005 等效項(xiàng) | ||||
---|---|---|---|---|---|
Alignment | | ||||
Appearance | | ||||
BackColor |
| ||||
Caption | | ||||
Container | | ||||
DisabledPicture DownPicture | 新的實(shí)現(xiàn)。有關(guān)更多信息,請(qǐng)參見 Style 屬性(針對(duì) Visual Basic 6.0 用戶)。 | ||||
DragIcon DragMode | 新的實(shí)現(xiàn)。有關(guān)更多信息,請(qǐng)參見拖放(針對(duì) Visual Basic 6.0 用戶)。 | ||||
Font FontBold FontItalic FontName FontSize FontStrikethrough FontUnderline |
| ||||
ForeColor |
| ||||
Height |
| ||||
HelpContextID | 新的實(shí)現(xiàn)。有關(guān)更多信息,請(qǐng)參見幫助支持(針對(duì) Visual Basic 6.0 用戶)。 | ||||
HWnd | | ||||
Index | 新的實(shí)現(xiàn)。有關(guān)更多信息,請(qǐng)參見控件數(shù)組(針對(duì) Visual Basic 6.0 用戶)。 | ||||
Left |
| ||||
MaskColor | 新的實(shí)現(xiàn)。有關(guān)更多信息,請(qǐng)參見 MaskColor(針對(duì) Visual Basic 6.0 用戶) | ||||
MouseIcon | 新的實(shí)現(xiàn)。有關(guān)更多信息,請(qǐng)參見無法設(shè)置自定義 MousePointer。 | ||||
MousePointer | 有關(guān)常數(shù)的列表,請(qǐng)參見 MousePointer(針對(duì) Visual Basic 6.0 用戶)。 | ||||
OLEDropMode | 新的實(shí)現(xiàn)。有關(guān)更多信息,請(qǐng)參見拖放(針對(duì) Visual Basic 6.0 用戶)。 | ||||
Parent | | ||||
Picture | | ||||
RightToLeft: True False | | ||||
Style |
| ||||
ToolTipText | 有關(guān)更多信息,請(qǐng)參見工具提示支持(針對(duì) Visual Basic 6.0 用戶)。 | ||||
Top |
| ||||
UseMaskColor | 新的實(shí)現(xiàn)。有關(guān)更多信息,請(qǐng)參見 MaskColor(針對(duì) Visual Basic 6.0 用戶)。 | ||||
Value | | ||||
WhatsThisHelpID | 新的實(shí)現(xiàn)。有關(guān)更多信息,請(qǐng)參見幫助支持(針對(duì) Visual Basic 6.0 用戶)。 | ||||
Width |
|
Visual Basic 6.0 | Visual Basic 2005 等效項(xiàng) | ||
---|---|---|---|
Drag | 新的實(shí)現(xiàn)。有關(guān)更多信息,請(qǐng)參見拖放(針對(duì) Visual Basic 6.0 用戶)。 | ||
Move |
| ||
OLEDrag | 新的實(shí)現(xiàn)。有關(guān)更多信息,請(qǐng)參見拖放(針對(duì) Visual Basic 6.0 用戶)。 | ||
SetFocus | | ||
ShowWhatsThis | 新的實(shí)現(xiàn)。有關(guān)更多信息,請(qǐng)參見幫助支持(針對(duì) Visual Basic 6.0 用戶)。 | ||
ZOrder | |
Visual Basic 6.0 | Visual Basic 2005 等效項(xiàng) | ||
---|---|---|---|
Click | CheckedChanged
| ||
DblClick | | ||
DragDrop DragOver | 新的實(shí)現(xiàn)。有關(guān)更多信息,請(qǐng)參見拖放(針對(duì) Visual Basic 6.0 用戶)。 | ||
GotFocus | | ||
LostFocus | | ||
OLECompleteDrag OLEDragDrop OLEDragOver OLEGiveFeedback OLESetData OLEStartDrag | 新的實(shí)現(xiàn)。有關(guān)更多信息,請(qǐng)參見拖放(針對(duì) Visual Basic 6.0 用戶)。 | ||
Validate | |
當(dāng) Visual Basic 6.0 應(yīng)用程序升級(jí)到 Visual Basic 2005 時(shí),任何 OptionButton 控件都升級(jí)為 Windows 窗體 RadioButton 控件,屬性、方法和事件升級(jí)為其各自等效項(xiàng)。在可能存在行為差異的情況下,向代碼中插入升級(jí)注釋。
聯(lián)系客服