当ca
当从一个子公司呼叫到另一个子公司时,你能保持字符串值吗?干杯
Col。 如果你不申报
e、 g.声明
(defun test1 (/ strng1)
(setq strng1 (getstring "Enter sumthin: "))
)
未申报的
(defun test2 ()
(setq strng2 (getstring "Enter sumthin else"))
)
如果您加载并运行这些函数!strng1将返回nil[对于其他sub不可用]!strng2将返回字符串[可用] 在VB中,您可以将其设置为模块级变量(即模块顶部的“Private varname as string”)或全局变量(即“Public varname as string”)。模块级可用于模块中的所有子模块/功能,全局可用于任何模块。这是一种方法,还有其他方法可以实现。 当然,您仍然可以使用局部变量,只需将第一个函数的结果作为参数传递给第二个函数。
;;; function 1 just sets a string to the var str
(defun fun1 ( / str)
(setq str "\nthis is a test string")
str
)
;;; function 2 expects an argument and prints it.
(defun fun2 (arg)
(princ arg)
)
;;; this code just calls function 2 with function 1 as an argument
(fun2 (fun1))
;;; when you are done, str is either
;;; nil or it's previous value before running
;;; any of this code.
你好
我正在使用Vb,并尝试将以下内容放在通用/声明部分的模块顶部
<p>Public MyAttTextStr As String</p><p> 对不起,实际上它确实有效!!
非常感谢!
col公司
页:
[1]