Hi Margret and All,
I have 2 function about manage string in VB 6.0 ,I need use in B4A . I cann't. Please help me to correct them I tried them ,have always error. this my code:
Sub StrCutTokenStrAll(Passedstring As String,TokenStr As String) As String
'This function to check 2 string be same data (i.e. "Book1" = "Book 1" )
Do Until InStr(Passedstring, TokenStr) = 0
Passedstring = Left(Passedstring, InStr(Passedstring, TokenStr) - 1) & Mid(Passedstring, InStr(Passedstring, TokenStr) + 1, Len(Passedstring) - InStr(Passedstring, TokenStr))
Loop
Return Passedstring
End Sub
Sub GetWord( StrVar As String,token As String, Nth As Int) As String
' This function returns the Nth token in a string
' Ex. msgbox GetWord("This is a test.", " ", 2) return "is"
Dim i As Int
Dim p As Int
Dim R As Int
Dim TargetStr As String
'*****************
TargetStr = " "
For i = 1 To Len(StrVar)
If Mid(StrVar, i, 1) = " " Then
If Mid(StrVar, i - 1, 1) <> " " Then
TargetStr = TargetStr + Mid(StrVar, i, 1)
End If
Else
TargetStr = TargetStr + Mid(StrVar, i, 1)
End If
Next
StrVar = Trim(TargetStr)
If Nth < 1 Then
Return ""
Exit
End If
R = 0
For i = 1 To Nth
p = R
R = InStr( p + 1,StrVar,token)
If R = 0 Then
If i = Nth Then
Return Mid(StrVar, p + 1, Len(StrVar) - p)
Else
Return ""
End If
Exit
End If
Next
Return Mid(StrVar, p + 1, R - p - 1)
End Sub
I have 2 function about manage string in VB 6.0 ,I need use in B4A . I cann't. Please help me to correct them I tried them ,have always error. this my code:
Sub StrCutTokenStrAll(Passedstring As String,TokenStr As String) As String
'This function to check 2 string be same data (i.e. "Book1" = "Book 1" )
Do Until InStr(Passedstring, TokenStr) = 0
Passedstring = Left(Passedstring, InStr(Passedstring, TokenStr) - 1) & Mid(Passedstring, InStr(Passedstring, TokenStr) + 1, Len(Passedstring) - InStr(Passedstring, TokenStr))
Loop
Return Passedstring
End Sub
Sub GetWord( StrVar As String,token As String, Nth As Int) As String
' This function returns the Nth token in a string
' Ex. msgbox GetWord("This is a test.", " ", 2) return "is"
Dim i As Int
Dim p As Int
Dim R As Int
Dim TargetStr As String
'*****************
TargetStr = " "
For i = 1 To Len(StrVar)
If Mid(StrVar, i, 1) = " " Then
If Mid(StrVar, i - 1, 1) <> " " Then
TargetStr = TargetStr + Mid(StrVar, i, 1)
End If
Else
TargetStr = TargetStr + Mid(StrVar, i, 1)
End If
Next
StrVar = Trim(TargetStr)
If Nth < 1 Then
Return ""
Exit
End If
R = 0
For i = 1 To Nth
p = R
R = InStr( p + 1,StrVar,token)
If R = 0 Then
If i = Nth Then
Return Mid(StrVar, p + 1, Len(StrVar) - p)
Else
Return ""
End If
Exit
End If
Next
Return Mid(StrVar, p + 1, R - p - 1)
End Sub