我有一个Xpath的命令类型,在这里我想嵌入命令是从一个变量中获取一个可更新的整数[1] ...在Xpath类型命令中添加变量是否有更好的方法? (VBA)
Set ActiveASIN = objxmldoc.selectSingleNode("//ns1:GetLowestOfferListingsForASINResult[i]/ns1:Product/ns1:Identifiers/ns1:MarketplaceASIN/ns1:ASIN")
但我能得到这个的唯一途径工作是建立在块上面的命令&然后串联....不优雅可言....
firstpart = "//ns1:GetLowestOfferListingsForASINResult[" + CStr(i) + "]"
secondpart = "/ns1:Product/ns1:Identifiers/ns1:MarketplaceASIN/ns1:ASIN"
complete = firstpart + secondpart
Set ActiveASIN = objxmldoc.selectSingleNode(complete)
...它只是不知道正确的语法或做我的情况下,它必须按照我以上所做的来完成?
也许这只是一个错字,但你知道,字符串连接使用'&'真的做,而不是'+'?请参阅:https://msdn.microsoft.com/de-de/library/gg278870.aspx – Oliver
在vba中的连接可以使用+或http://stackoverflow.com/questions/3365197/vba-difference-between-而VBA中的 – montewhizdoh
对于“优雅”来说,你是有限的。你可以使用split()和join(),你可以使用Replace(),或者你可以在代码中使用连接运算符。 https://blog.udemy.com/vba-string-functions/ – montewhizdoh