因此,我正在嘗試的是在Button1單擊時使用所選Radiobutton和Checkboxes創建一個MessageBox。單擊button1時在msgbox上顯示選中的單選按鈕和複選框VB
這裏的設計:
而且我所要的輸出是這樣的:
謝謝你做的
因此,我正在嘗試的是在Button1單擊時使用所選Radiobutton和Checkboxes創建一個MessageBox。單擊button1時在msgbox上顯示選中的單選按鈕和複選框VB
這裏的設計:
而且我所要的輸出是這樣的:
謝謝你做的
更好的辦法這是循環通過groupbox控件並檢查複選框是否被選中,如果是,則將其附加到某些str ing.And畢竟你檢查完成顯示器使用messagebox.Simple字符串作爲它is.To提供一些更多的光解決方案請進行下面的代碼
通過控制
Dim strfinal As String
For Each gb As Control In Me.Controls
If gb.GetType() Is GetType(GroupBox) Then
Dim str As String
str = gb.Text
For Each c As CheckBox In gb.Controls
If c.Checked = True Then
str = str + vbNewLine + c.Text
End If
Next
If str <> "" Then
strfinal = strfinal + vbNewLine + str
End If
End If
Next
和顯示循環在messagebox
If strfinal <> "" Then
MessageBox.Show(strfinal, "somecaption", MessageBoxButtons.OK)
End If
希望這可以幫助。
這個代碼將會給你的結果完全按照圖片2以上:
Dim Toppings As String = "Toppings:" & VbCrlf
Dim TSize As String = "Size:"
Dim CrustType As String = "Crust Type:"
在這裏,當你按下Button1的,當包含餡料的groubBox的名稱是「ToppingsGroupBox」和相同對於其他groupBoxes:
For Each CB As CheckBox In ToppingsGroupBox.Controls
If CB.Checked Then
Toppings &= "-" & CB.Text & VbCrlf
End If
End Each
For Each RB As RadioButton In SizesGroupBox.Controls
If RB.Checked Then
TSize &= RB.Text
End If
End Each
For Each RB As RadioButton In CurstTypeGroupBox.Controls
If RB.Checked Then
CurstType &= RB.Text
End If
End Each
If DineInRadioBox.Checked Then
MsgBox(TSize & VbCrlf & CurstType & Toppings & "*Dine In")
Else
MsgBox(TSize & VbCrlf & CurstType & Toppings & "*Take Out")
End If
希望這將幫助你:)
所以,你想要得到的檢查博文xes或他們的狀態? –
@MousaAlfhaily是的,類似於Picture2上的東西。只是選定的RadioButtons和CheckBoxes的文本。 –
是的,這是可以做到的,我打算爲你解答一個問題。 –