VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



A function which Returns a zero-based, one-dimensionalarray containing a specified number of substr

by Sourabh Wathodkar (3 Submissions)
Category: String Manipulation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sat 19th May 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

A function which Returns a zero-based, one-dimensionalarray containing a specified number of substrings .Please ignor if any error occurs this

API Declarations


'Use Like this
'u can use any separator , . @ etc.
dim StrTemp
StrTemp=GetWord(Text1.text,",")


Rate A function which Returns a zero-based, one-dimensionalarray containing a specified number of substr



On Error GoTo GetWord_error
    Dim P, S, L, I As Integer
    Dim Temp1 As String
    Dim GetWords() As String
    Temp1 = Replace(strText, Separator, "")
    S = (Len(strText) - Len(Temp1)) / Len(Separator)
    S = S
    ReDim GetWords(S)
    If S > 0 Then
        L = Len(strText)
        For I = 0 To S
             P = InStr(strText, Separator)
             If P = 0 Then
                GetWords(I) = strText
                Exit For
             Else
                GetWords(I) = Mid(strText, 1, P - 1)
                strText = Mid(strText, P + 1, L)
                L = Len(strText)
             End If
        Next
    Else
        GetWords(S) = strText
    End If
    GetWord = GetWords
    Exit Function

GetWord_error:
    GetWord = ""
    Exit Function
End Function

Download this snippet    Add to My Saved Code

A function which Returns a zero-based, one-dimensionalarray containing a specified number of substr Comments

No comments have been posted about A function which Returns a zero-based, one-dimensionalarray containing a specified number of substr. Why not be the first to post a comment about A function which Returns a zero-based, one-dimensionalarray containing a specified number of substr.

Post your comment

Subject:
Message:
0/1000 characters