引用 | 编辑
troy_liaw106
2011-01-28 19:26 |
楼主
▼ |
||
|
引用 | 编辑
ebolaman
2011-01-28 22:19 |
1楼
▲ |
||||||||||
我之前在网路上看到有种方法,是用 For Each...Next 的方式来储存与读取
在此我做了个范例专案 关键的程式码如下: 读取部分: 复制程式 '------------------- For Each Ctl In Me tempInd = GetObjIndex(Ctl) tempName = GetCtlName(Ctl.Name, tempInd) m = DetectNamePlace(S, tempName) If m <> 0 Then '---------------- All Types of Objects -------------- On Error Resume Next Select Case TypeName(Ctl) Case "TextBox" Ctl.Text = GetValueAfterEqual(S, tempName, m) Case "CheckBox" Ctl.Value = GetValueAfterEqual(S, tempName, m) Case "OptionButton" Ctl.Value = GetValueAfterEqual(S, tempName, m) End Select '---------------------------------------------------- End If Next '------------------- 储存部分: 复制程式 '------------------- For Each Ctl In Me '---------------- All Types of Objects -------------- Select Case TypeName(Ctl) Case "TextBox" tempS = Ctl.Text Case "CheckBox" tempS = Ctl.Value Case "OptionButton" tempS = Ctl.Value End Select '---------------------------------------------------- tempInd = GetObjIndex(Ctl) Print #f, GetCtlName(Ctl.Name, tempInd) & "=" & tempS Next '------------------- Control 是表单中所有可控制的元件 (控制项) 我加了很多 Function ,功能如下 (以下用 Ctl 简称控制项、S 简称 Set.ini 的内容): LoadEntireFile - 将某个档案内的文字全部读取 GetObjIndex - 传回某 Ctl 的 Index ,不是群组物件则传回 -1 GetCtlName - 将 Ctl 的名称与 Index (如果有) 混合成标准的元件名称 DetectNamePlace - 用 InStr 取得 元件名称的设定值在 S 中的位置 GetValueAfterEqual - 取得 S 中某元件的数值 请参考此范例:
![]() |