下次保存用户表单值 [英] Save userform value for next time
本文介绍了下次保存用户表单值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望用户在设置页面的文本框中输入路径,并在每次加载用户表单时使用此路径字符串.用户不必在每次打开用户表单时都输入路径.
I want users to enter a path into a textbox in a settings page and use this path-string each time they load the userform. The users should not have to enter the path each time they open the userform.
在Internet上找不到任何有关下次保存用户表单输入值的信息,这些信息已加载.
I can't find anything on the internet about saving input values of userforms for the next time, they are loaded.
推荐答案
我建议使用 SaveSetting应用程序名称,部分,键,设置
来存储数据和 GetSetting appname,部分,键[,默认]
来检索值.
I recommend using SaveSetting appname, section, key, setting
to store data
and GetSetting appname , section, key [, default ]
to retrieve values.
以您的示例为例:
Private Sub UserForm_Terminate()
'
' Save Setting to the windows registry
' usually values are stored at the following path:
' Computer\HKEY_USERS\{user-guid}\Software\VB and VBA Program Settings
'
SaveSetting "YourApplication", "UserFormXYZ", "TextBox1", TextBox1.Text
End Sub
Private Sub UserForm_Initialize()
dim defaultPath As String
dim userPath As String
' set defaultPath as you require
' get settings from Registry
userPath = GetSetting("YourApplication", "UserFormXYZ", "TextBox1", defaultPath)
TextBox1.Text = userPath
End Sub
这篇关于下次保存用户表单值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文