Click here to Skip to main content
14,735,206 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
strBd.Append("<%ShowFiles()%>") it's not working for me

What I have tried:

I tired (') and (&) but not working
Updated 2-Nov-16 3:59am
phil.o 2-Nov-16 8:40am
Can you define 'not working'? What do you expect? What do you actually get?

It does exactly what I expected:
Dim strBd As New StringBuilder
strBd.Append("Start: ")
strBd.Append(" :End")

Gives me:
Start: <%ShowFiles()%> :End
It's a string: when you append otehr strings, it adds them into the string so far.
If that isn't what you wanted it to do, you need to either rethink what you are trying to do, or explain in much better detail exactly what you do expect it to do.
[no name] 2-Nov-16 9:09am
I guess he wants the return value of a Function, probably by using the same technique as the Environ variables or the $ prefix. Am not sure if this is possible in this case.
OriginalGriff 2-Nov-16 9:15am
Yeah, it's difficult to tell - it may well be that he's trying to pass it to his Client as Javascript to get it to call the function on his which case he needs to think about what he's doing rather more! :laugh
Sunny Gajjar 2-Nov-16 9:18am
Thanks for your replay but I sorted the think by other way and its working
If you are trying to append the return value of a Function then do the following;

sb.Append("<%" & ShowFiles().ToString() & "%>")
sb.AppendFormat("<%{0}%>", {ShowFiles().ToString()}) 'where 0 is the index of the parameter array
Richard Deeming 2-Nov-16 11:08am
There's a typo in your AppendFormat example. It should be:
sb.AppendFormat("<%{0}%>", ShowFiles())

* You need curly braces within the format string, not parentheses;
* You don't need to wrap the other arguments in curly braces;
* You don't need to call ToString on the result of the method, and doing so might cause a NullReferenceException;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900