Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Question to VB gurus
Message
From
03/06/2015 09:02:42
 
 
To
22/05/2015 13:26:27
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01620102
Message ID:
01620568
Views:
59
thanks

>
>
>    ' Equivalent of VFP StrTran()
>    ' expC1 String
>    ' expC2 Search for specific character
>    ' expC3 Replace
>    Public Function StrTran(ByVal tcSearchIn As String, ByVal tcSearchFor As String, _
>     ByVal tcReplace As String) As String
>        Return tcSearchIn.Replace(tcSearchFor, tcReplace)
>    End Function
>
>    ' Equivalent of VFP StrTran()
>    ' This one should not be called in intensive way as this could cause and Out of memory issue.
>    ' It is supported here for processing large chuncks of text such as a big memo field where you would have
>    ' a large number of calls to make to replace some strings. In that particular situation, it would be faster than
>    ' StrTran(). This has to be analysis on a per basis usage.
>    ' expC1 String
>    ' expC2 Search for specific character
>    ' expC3 Replace
>    Public Function StrTranStringBuilder(ByVal tcSearchIn As String, ByVal tcSearchFor As String, _
>     ByVal tcReplace As String) As String
>        Dim loStringBuilder As StringBuilder = New StringBuilder(tcSearchIn)
>        Return loStringBuilder.Replace(tcSearchFor, tcReplace).ToString()
>    End Function
>
>    ' Equivalent of VFP StrTran() with case insensitive
>    ' expC1 String
>    ' expC2 Search for specific character
>    ' expC3 Replace
>    Public Function StrTranCaseInsensitive(ByVal tcSearchIn As String, ByVal tcSearchFor As String, _
>     ByVal tcReplace As String) As String
>        Dim lnLength As Integer = tcSearchIn.Length
>        Dim lnLengthSearchFor As Integer = tcSearchFor.Length
>        Dim lnLocation As Integer = 0
>        Dim loStringBuilder As New StringBuilder(lnLength)
>
>        ' Check inputs
>        If lnLength = 0 Or lnLengthSearchFor = 0 Or lnLengthSearchFor > lnLength Then
>            Return tcSearchIn
>        End If
>
>        While lnLocation + lnLengthSearchFor <= lnLength
>
>            If String.Compare(tcSearchIn, lnLocation, tcSearchFor, 0, lnLengthSearchFor, True) = 0 Then
>
>                ' Add the replaced string
>                loStringBuilder.Append(tcReplace)
>
>                lnLocation = lnLocation + lnLengthSearchFor
>            Else
>
>                ' Advance one character
>                loStringBuilder.Append(tcSearchIn, lnLocation, 1)
>                lnLocation = lnLocation + 1
>
>            End If
>
>        End While
>
>        ' Append remaining characters
>        loStringBuilder.Append(tcSearchIn, lnLocation, lnLength - lnLocation)
>
>        Return loStringBuilder.ToString()
>    End Function
>
Peter Cortiel
Previous
Reply
Map
View

Click here to load this message in the networking platform