如何使窗体刷新,重新加载?

shenyang1007 2003-12-17 10:46:01
我现在在一个窗体中修改了参数,保存在INI文件中,然后让主窗体不重新启动而直接读取INI文件,并改变界面参数显示!
...全文
279 点赞 收藏 8
写回复
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
longki 2003-12-17

Private sub form_load()
Call 初始化程序()
end sub


Private sub 初始化程序()
...............
初始化代码...
...............
end sub

最后在需要刷新的事件中调用"初始化程序()"就OK了吧!
回复
IT服务 2003-12-17
"SoHo_Andy(冰)"is a high hand.
回复
jhzhou882 2003-12-17
冰哥哥小弟佩服的紧.
写代码神速呀.
回复
SoHo_Andy 2003-12-17

完整示例代码如下,测试通过
功能通过读写ini文件来控制状态,窗体不重新加载

模块中
Option Explicit

'-------------------------
'声明
Declare Function WritePrivateProfileString Lib "Kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
Declare Function GetPrivateProfileString Lib "Kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long

'获得设置
Public Function MyGetSetting(Section As String, KeyName As String, DefaultValue As String) As String

Dim x As Long
Dim Holder As String * 255

x = GetPrivateProfileString(Section, KeyName, DefaultValue, Holder, 254, "d:\aaa.ini")
MyGetSetting = Left$(Holder, InStr(Holder, Chr$(0)) - 1)

End Function

'保存设置
Public Sub MySetSetting(Section As String, KeyName As String, KeyValue As String)

Dim x As Long

x = WritePrivateProfileString(Section, KeyName, KeyValue, "d:\aaa.ini")

End Sub


窗体中
Private Sub Command2_Click()
Command2.Enabled = False
MySetSetting "设置", "控件状态", "禁用"
End Sub

Private Sub Command3_Click()
If MyGetSetting("设置", "控件状态", "") = "禁用" Then
Command2.Enabled = True
End If
End Sub
回复
IT服务 2003-12-17
call form_load()
call form_activate()
回复
jhzhou882 2003-12-17
再调一次 LOAD或者初始化事件
回复
aalei 2003-12-17
form1.refresh
回复
IT服务 2003-12-17
form1.refresh
回复
发动态
发帖子
VB基础类
创建于2007-09-28

7451

社区成员

VB 基础类
申请成为版主
社区公告
暂无公告