例程从用户请求路径 [英] Routine to request a path from user

查看:40
本文介绍了例程从用户请求路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友们好,

有人可以帮忙制作一个例程吗?它使用输入框询问用户是否有必要的文件夹路径?我想在我的用户表单中将路径设置为公共变量变量,并在此用户表单运行时在其他例程中使用它。

Can somebody help to make a routine which uses input box to ask user for a path to a required folder? I want to set path as a Public Variant Variable in my User form and use it later in other routines while this User Form is running.

然而,这里的挑战是我不想要让用户每次打开用户表单时输入路径。这意味着我第一次要求用户输入路径,当他/她关闭我的用户表单并再次打开它时,路径在例程中保存
并且不会打扰用户每次键入路径时间用户表单已打开。

However, the challenge here is that I do not want to ask user to type in the path every time he/she opens user form. Meaning that at the first time I ask user to type in the path and when he/she closes my user form and opens it again, the path stays saved in the routine and does not bother user to type in the path every time user form is opened.

非常感谢!

Public Path As Variant

Public Path As Variant

Path = InputBox(提示:="请输入包含数据记录文件的文件夹的路径",标题:="路径设置")

Path = InputBox(prompt:="Please, type in the path of a folder containing datalog files", Title:="Path settings")

推荐答案

将公共路径作为Variant(应该是String not Variant)语句放在模块的顶部,并保留其内容,直到您关闭文件或在VBE中休息。

Put the Public Path as Variant (should be String not Variant) statement at the top of a Module and its contents are maintained until you close the file or do a rest in the VBE.

您还可以使用SaveSetting和GetStting方法(请参阅帮助)将路径安全地保存在注册表中,以使值保持不变直到覆盖,并在下次打开项目时可用。

You can also use the SaveSetting and GetStting methods (see help) to safely save the path in the registry so the value survives until over-written and is available next time you open the project.


这篇关于例程从用户请求路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆