主要有几种方法: 1存到数据库;2存到文本文件;3存到Ini文件;4存到注册表后两种比较方便,下面代码演示了如何存到注册表,要试用下列代码请在窗体上加两个文本框和一个按钮,然后将下列代码拷贝到窗体内: Private strSave(2) As StringPrivate Sub Command1_Click() strSave(1) = Text1.Text strSave(2) = Text2.Text End Sub Private Sub Form_Load() strSave(1) = GetSetting(App.ProductName, "Save", "Key1") strSave(2) = GetSetting(App.ProductName, "Save", "Key2") Text1.Text = strSave(1) Text2.Text = strSave(2) End Sub Private Sub Form_Unload(Cancel As Integer) SaveSetting App.ProductName, "Save", "Key1", strSave(1) SaveSetting App.ProductName, "Save", "Key2", strSave(2) End Sub
1存到数据库;2存到文本文件;3存到Ini文件;4存到注册表后两种比较方便,下面代码演示了如何存到注册表,要试用下列代码请在窗体上加两个文本框和一个按钮,然后将下列代码拷贝到窗体内:
Private strSave(2) As StringPrivate Sub Command1_Click()
strSave(1) = Text1.Text
strSave(2) = Text2.Text
End Sub
Private Sub Form_Load()
strSave(1) = GetSetting(App.ProductName, "Save", "Key1")
strSave(2) = GetSetting(App.ProductName, "Save", "Key2")
Text1.Text = strSave(1)
Text2.Text = strSave(2)
End Sub
Private Sub Form_Unload(Cancel As Integer)
SaveSetting App.ProductName, "Save", "Key1", strSave(1)
SaveSetting App.ProductName, "Save", "Key2", strSave(2)
End Sub