This is a migrated thread and some comments may be shown as answers.

expression check if string

2 Answers 349 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 04 Apr 2014, 01:02 PM
Hello,

i set a filter to check if my value (from Database) is a String. I don't know how to do it properly. So i use my own Function:

Public Shared Function CheckForAlphaCharacters(ByVal StringToCheck As String) As Boolean
 
    Try
        Dim i As Integer = 0
        For i = 0 To StringToCheck.Length - 1
            If Char.IsLetter(StringToCheck.Chars(i)) Then
                Return True
            End If
        Next
        Return False
    Catch ex As Exception
        Return False
    End Try
 
End Function

An this is how i define the filter. (I also added a screenshot)

= MIR.Web.ZinsCheck.Hilfsfunktion.CheckForAlphaCharacters(CStr(Fields.Beschäftigungsverhältnis2)) = True = = True

What I want is, if the Value is Empty the row not visible.

So this wont work. What i'm doing wrong?

But I am also open to other solutions!

Thank you,
Daniel

2 Answers, 1 is accepted

Sort by
0
Accepted
Peter
Telerik team
answered on 07 Apr 2014, 04:15 PM
Hi Daniel,

Our recommendation is to change the user function as shown below:
Public Shared Function CheckForAlphaCharacters(ByVal StringToCheck As Object) As Boolean
  
    Try
        Dim i As Integer = 0
    Dim stringVar = DirectCast(StringToCheck , String)
        For i = 0 To stringVar.Length - 1
            If Char.IsLetter(StringToCheck.Chars(i)) Then
                Return True
            End If
        Next
        Return False
    Catch ex As Exception
        Return False
    End Try
  
End Function

Then you don't have to cast the data field:
= CheckForAlphaCharacters(Fields.Beschäftigungsverhältnis2)    =   =True

Regards,
Peter
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Daniel
Top achievements
Rank 1
answered on 07 Apr 2014, 06:46 PM
Thank you!
Daniel
Tags
General Discussions
Asked by
Daniel
Top achievements
Rank 1
Answers by
Peter
Telerik team
Daniel
Top achievements
Rank 1
Share this question
or