function used?

desperateboy

Active member
Joined
Dec 11, 2007
Messages
30
Programming Experience
Beginner
hi friends
I have s/w in vb6.I want to onvert it into vb.net.In the module section, this funtion is used.I didn't understand what does it mean?
VB.NET:
Function CHKR(a As String) As Boolean
    Dim x As String * 1, j As Integer
    x = Left(Trim$(a), 1)
    For j = 1 To Len(sRight)
        If Mid(sRight, j, 1) = x Or Mid(sRight, j, 1) = "A" Then
            CHKR = True
            Exit Function
        Else
            CHKR = False
        End If
    Next
z:
End Function
If u understand this code.why is it use.Plz tell

thanks
 
Last edited by a moderator:
It loops through a string looking for a certain character or a capitol A, I have no idea what it's purpose is in the grand scheme of the program without seeing the actual program.

Here's a .Net version of it, I've also cleaned it up a little too:
VB.NET:
Function CHKR(ByVal a As String) As Boolean
    Dim x As String = a.Trim.SubString(0I, 1I)
    For j As Integer = 0I To sRight.Length - 1I
        If sRight.SubString(j, 1I) = x OrElse sRight.SubString(j, 1I) = "A" Then Return True
    Next j
    Return False
End Function
 
Allow me to clean it up some more for you:

VB.NET:
Function CHKR(ByVal a As String) As Boolean
    Return sRight.Contains("A") OrElse sRight.Contains(a.TrimStart()(0)) 
End Function
 
Back
Top