我有一个Sub,它包含一个参数字符串,并将其包含在命令文本中。我的问题是执行在命令行中不接受字符串(由于引号)。是否可以将命令文本等同于字符串并使系统不考虑引号?谢谢
Public Sub CreatView(ByVal NomeView As String)
NomeView ="View1" 'example
Dim Com As String
Dim Comando As Command
Set Comando = New Command
Com = "StringView_123.Value"
Com = Replace(Com, "123", NomeView)
Comando.CommandText = Com 'Don't work
Comando.CommandText = StringView_View1.Value 'Work fine
Aplicacao.BSO.DSO.BDAPL.Execute (Comando.CommandText)
End Sub
答案 0 :(得分:0)
这些是字符串变量(NomeView,Com):
NomeView ="View1"
Com = "StringView_123.Value"
这是一个字符串属性(CommandText是Comando对象的text属性):
Comando.CommandText = Com
StringView_123
看起来像控件的名称(可能是文本框?),它具有Value
属性。
这些行似乎需要更改:
Com = "StringView_123.Value"
Com = Replace(Com, "123", NomeView)
收件人:
Com = StringView_123.Value
Com = Replace(Com, "123", NomeView)
控件名称和属性的引号表示您正在使用字符串值(“ StringView_123.Value”),而不是控件的名称(StringView_123)
答案 1 :(得分:0)
我用CallByName替换了“命令文本”,我的战斗处于“价值”状态(定位不佳)。
Public Sub CreatView(ByVal NomeView As String)
NomeView ="View1" 'example
Dim Com As String
Com = "StringView_123"
Com = Replace(Com, "123", NomeView)
Aplicacao.BSO.DSO.BDAPL.Execute (CallByName(Me, Com, VbMethod).Value)
End Sub