On March 9th, the date when the selected check1, how to preserve the state of check1, when next time choosing a March 9 check1 or selected in shift
CodePudding user response:
Record state to a file or registry, next to interface using extracted Settings, principle is like this, write their own codeCodePudding user response:
Search SaveSettings in the MSDNCodePudding user response:
The DEMO interface:The DEMO code:
Need to add references "Microsoft Scripting Runtime".
Option Explicit
Private mdctChecks As New Dictionary
Private Sub UpdateMemory (ByVal CHK As CheckBox)
MdctChecks. Item (CHK. Name). The Item (DTPicker1. Value)=CHK. Value
End Sub
Private Sub Command1_Click ()
UpdateMemory Check1
UpdateMemory Check2
End Sub
Private Sub Command2_Click ()
UpdateMemory Check3
UpdateMemory Check4
End Sub
Private Sub Command3_Click ()
UpdateMemory Check5
UpdateMemory Check6
End Sub
Private Sub UpdateScreen ()
Dim CTRL As Control
For Each control In the Me. Controls,
If TypeOf CTRL Is CheckBox Then
If mdctChecks. Item (CTRL. Name). The Exists (DTPicker1. Value) Then
CTRL. Value=https://bbs.csdn.net/topics/mdctChecks.Item (CTRL. Name). The Item (DTPicker1. Value)
The Else
CTRL. Value=https://bbs.csdn.net/topics/vbUncheckedEnd the If
End the If
Next
End Sub
Private Sub DTPicker1_Change ()
UpdateScreen
End Sub
Private Sub Form_Load ()
Dim CTRL As Control
For Each control In the Me. Controls,
If TypeOf CTRL Is CheckBox Then
MdctChecks. Add CTRL. The Name, the New Dictionary
End the If
Next
Dim varKey As the Variant
For Each varKey mdctChecks In
Dim strData As String
StrData=https://bbs.csdn.net/topics/GetSetting (App) EXEName, "Section", varKey, "")
Dim arrData () As String
ArrData=(strData, ", "https://bbs.csdn.net/topics/Split
Dim As Integer I
For I=LBound (arrData) To UBound (arrData)
Dim arrData2 () As String
ArrData2=Split (arrData (I), "=")
MdctChecks. Item (varKey). The Item (CDate (arrData2 (0)))=arrData2 (1)
Next
Next
UpdateScreen
End Sub
Private Sub Form_Unload (Cancel As Integer)
Dim varKey As the Variant
For Each varKey mdctChecks In
Dim strData As String
strDatahttps://bbs.csdn.net/topics/=""
Dim varKey2 As the Variant
For Each varKey2 In mdctChecks. Item (varKey)
StrData=https://bbs.csdn.net/topics/strData & varKey2 & "=" & amp; MdctChecks. Item (varKey). The Item (varKey2) & amp; ", "
Next
If Right (strData, 1)=", "Then
StrData=https://bbs.csdn.net/topics/Left (strData, Len (strData) - 1)
End the If
SaveSetting App. EXEName, "Section", varKey, strData
Next
End Sub
Download DEMO:
Link: https://pan.baidu.com/s/1E7HybFLe7SUfgSRyNFoJpg
The extracted code: ylem
CodePudding user response: