• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2707
  • Last Modified:

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
0
psionic086
Asked:
psionic086
  • 3
  • 3
  • 3
1 Solution
 
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
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 3
  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now