0
변수가 Month1 & Month2인데, 어떻게 든 cb_CheckedChanged에서 frmMain_Load로 전송해야합니다. 문자열 값을 전송할 방법이없는 경우 코드를 변경하여 가능하게 할 수 있습니까?서브 루틴을 통해 문자열 값을 전송하는 중
Public Class frmMain
Private Sub cb_CheckedChanged(sender As Object, e As EventArgs) Handles chckJan.
CheckedChanged,
chckFeb.CheckedChanged,
chckMar.CheckedChanged,
chckApr.CheckedChanged,
chckMay.CheckedChanged,
chckJun.CheckedChanged,
chckJul.CheckedChanged,
chckAug.CheckedChanged,
chckOct.CheckedChanged,
chckNov.CheckedChanged,
chckDec.CheckedChanged
'get all checkboxes
Dim Months = Controls.OfType(Of CheckBox)().ToArray()
'Get the number of checked CheckBoxes.
Dim checkedBoxCount = Months.Count(Function(cb) cb.Checked)
'Unchecked CheckBoxes should be enabled if and only if the number of checked CheckBoxes is less than the maximum number allowed.
Dim enableUncheckedBoxes = checkedBoxCount < 2
'Get the unchecked CheckBoxes.
Dim uncheckedBoxes = Months.Where(Function(cb) Not cb.Checked)
'Enable or disable the unchecked CheckBoxes as appropriate.
For Each uncheckedBox In uncheckedBoxes
uncheckedBox.Enabled = enableUncheckedBoxes
Next
Dim Month1 As String
Dim Month2 As String
Dim CheckBoxArray1 As CheckBox() = {chckJan, chckFeb, chckMar, chckApr, chckMay, chckJun, chckJul, chckAug, chckSep, chckOct, chckNov, chckDec}
For Each CheckBox In CheckBoxArray1
If CheckBox.Checked = True And checkedBoxCount = 1 Then
Month1 = CheckBox.Name.ToString
End If
Next
Dim CheckBoxArray2 As CheckBox() = {chckJan, chckFeb, chckMar, chckApr, chckMay, chckJun, chckJul, chckAug, chckSep, chckOct, chckNov, chckDec}
For Each CheckBox In CheckBoxArray2
If CheckBox.Checked = True And checkedBoxCount = 2 Then
Month2 = CheckBox.Name.ToString
End If
Next
End Sub
Private Sub frmMain_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
합니다. frmMain_Load는 'Load' 이벤트에서 실행되는 루틴입니다.'Handles MyBase.Load' –
FormLoad는 한 번만 실행되고 어떤 체크 박스도 체크하기 전에 – Plutonix
핸들을 돌릴 수있는 방법이 있나요 ??? @Jezzabeanz – SkyTreees