How to compare text string in reporting services with a custom code

Hi,

I need to compare the final part of long text string which is defaultly loaded from sql table on report.
This string is a text note and and always at the end is placed a name of the person who want to have his own stamp shown above his signature. This is true only in one case, only for one person who is administrative, others doesnt use stamps.
So I need to locate if his name is in the text and by comparison (probably written in custom code of report) I can condition if stamp will be shown on report or not.
The next competition is that I need to edit original text and exactly this name cut off, because stamp should be shown above his name. So I will show stamp based on comparison with the name located in text note, show original note without his name on the end and show his name above the stamp.
I know how to show things in RS, but editation of custom code based on strings is for me no-no. If you know how to write this simple task you are welcome! Thanks
psionic086Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sureshbabukrishCommented:
can you provide me sample data, and what you want to do, so that i can guide you appropriately
0
psionic086Author Commented:
sureshbabukrish:

I have already created report which works fine, and for one column called "note" from table I need to apply this scenario:
This note is such a text: "reminder for your forgotten something like this and that...  sincerely yours: Top accountant David Brynykli".
This note can vary from report to report, different people from accountant office shows her, its user changeable and I need to apply my conditions only in case that it contains name of David Brynykli (top accountant) which means that report will contain image of his stamp (I assume image of that stamp will be defaultly placed on report and I can show it by setting attribute hidden to false, based just on the name of that accountant David Brynykli).
I hope its understandable, but I really dont know how to condition this image showing in this one case. I know VB has something for getting last few characters of code, where I should catch the name of that accountant. Reporting services has as you know custom code tool where I should be able to use that code, but I am really novice to VB..
0
psionic086Author Commented:
OK thanks,

it was easier than I thought.. Just use Right, Left and Len string operators.. But I can use it only in case that name of my accountant is exactly at the end of the string. So it must look like "...... David Brynykli" if the name is somewhere else it wont work.. Do you know any string operator which I can use for return his name if places anywhere in the string?
0
Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

sureshbabukrishCommented:
use this in custom code

Function CheckString(SearchString as String , SourceString as String) as Boolean
Dim RetValue As Boolean
RetValue = "False"
if Instr(1,SourceString,SearchString ) > 0
RetValue = "True"
else
RetValue = "False"
end if
Return RetValue
End Function


use this in expression of the textbox properties

=code.CheckString("ABC",Fields!Panel.Value)
0
sureshbabukrishCommented:
Fields!Panel.Value would be any field where you compare/search the name in ( probably note field)
0
planoczCommented:
You could do this also...
Public Function CheckName(ByVal MyData As String) As Boolean
        MyData  = MyData .ToLower
        If MyData.System.Contains("john doe") = True  Then
             Return True
       End If
         Return False
End Function

john doe is where the admin name should be.
0
psionic086Author Commented:
Thanks sureshbabukrish and planocz, both works. The final step is to remove the name of the accountant from original text box. Because I am showing it under the stamp so there shouldn be his name replicated.
Only method which I am using now is to remove last 20 characters but it isnt so universal in many cases..
Please if you know any method how to "substract" the searched text string from first textbox it will be completely resolved.
0
planoczCommented:
Try this

 Public Function ClearName(ByVal strIn As String) As String
         Return System.Text.RegularExpressions.Regex.Replace(strIn, "John Doe]", "")
    End Function
=Code.ClearName(Trim(Fields!Text.Value))
0
planoczCommented:
Sorry miss spelling....
 
Public Function ClearName(ByVal strIn As String) As String
         Return System.Text.RegularExpressions.Regex.Replace(strIn, "John Doe", "")
    End Function
=Code.ClearName(Trim(Fields!Text.Value))
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
SSRS

From novice to tech pro — start learning today.