2020年8月31日 星期一

vb.net 新增字串到String()裡 [add String to String Array]

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
    Private Function Cortes(strText As String) As String()
        Dim strCorte As String
        strCorte = Split(strText, ") = ")(0)

        Dim intIndex As Integer = strCorte.LastIndexOf("(")
        Dim strCompleto As String = strCorte.Substring(0, intIndex - 1)
        Dim strAbreviado As String = strCorte.Substring(intIndex + 1, strCorte.Length - (intIndex + 1))

        Dim strReturn(0) As String
        strReturn(0) = strCompleto
        strReturn = AddElementToStringArray(strReturn, strAbreviado)

        Return strReturn
    End Function


1
2
3
4
5
6
    Public Function AddElementToStringArray(myStrings() As String, stringToAdd As String) As String()
        Dim myStringElements As Integer = myStrings.Length + 1
        ReDim Preserve myStrings(1)
        myStrings(myStringElements - 1) = stringToAdd
        Return myStrings
    End Function

沒有留言:

張貼留言