以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  关于单元格内字符串转换为代码  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=126540)

--  作者:15528900289
--  发布时间:2018/10/23 22:07:00
--  关于单元格内字符串转换为代码
老师您好:
1,如何将单元格内的字符串转换为可执行代码
例如:
Dim str1 As String = Tables("状态栏").Value(0,1)        ’Tables("状态栏").Value(0,1)中的值为: "用户: " & User.Name
Dim Str2 As String = "用户: " & User.Name
\'StatusBar.Message1 = Str2
output.show("str1值:  "&str1 & vbcrlf &"str2值:  "& str2 )
但是他们的输出结果不同:
str1值:  "用户: " &  User.Name
str2值:  用户: 开发者


str1的值内的代码执行,我试过了了eval函数、合成表达式cexp(),把字符才分解在重新组合都不行、麻烦老师给予指导,谢谢。

--  作者:有点蓝
--  发布时间:2018/10/23 22:18:00
--  
需要使用动态函数:http://www.foxtable.com/webhelp/scr/1487.htm

Functions.remove("函数")
Dim Code As String
Dim str1 As String = Tables("状态栏").Value(0,1) 
Code = "output.show(""str1 值:  "" & " & str1 & ")"
\'Code = "StatusBar.Message1 = ""str1 值:  "" & " & str1
Functions.Add("函数",Code)
Functions.Complie()
Functions.Execute("函数")