If you're only interested in getting a single value from Evaluate, you don't need to Dim a Variant to containt the Array Evaluate (almost) always returns.
Simply implode the evaluate, and you can assign the Evaluate directly.
Dim commonUsername As String
commonUsername = Implode( Evaluate( |@Name( [CN] ; @UserName )| ) )
9 comments:
Brilliant! I love tips like this and I hate dimming variants just to get one value.
Very nice little trick, Tommy! Thanks for sharing!
I can't believe I never thought of that before. This has bugged me for years. I always wanted to do this instead:
Evaluate(|@Name([CN]; @UserName)|)(0)
Now I don't have to declare that useless temporary Variant variable anymore.
Thanks!
Nice one, Tommy!
I'm curious... why Implode instead of it's shorter alias Join?
I guess because of reading co-workers code, and being influenced by the formula-language, which @Implodes.
I think I'll try to change my habit, since, as one commenter on Codestore said, Join is three letters shorter than Implode, and split/join is also what those "operations" are called in JavaScript.
I also think split/join are better descriptions of what is goin on.
Very very cool. Tried it out and started using it for application which is roll out to production.
You have to express more your opinion to attract more readers, because just a video or plain text without any personal approach is not that valuable. But it is just form my point of view
Does anyone know why this returns a empty string..?
Note it works if I replace s with "abcdefgh" in the actual evaluate...
Dim v as variant
Dim s as string
s = "abcdefgh"
v = Evaluate({@Middle(s; "B"; "H")})
msgbox v(0)
Should return "cdefg" but returns blank string?
Dim v as String
Dim s as String
s = "abcdefgh"
v = Join( Evaluate({@Middle("} + s + {"; "B"; "H")}) )
MsgBox v
Post a Comment