Sub raccourcir() Dim cestlong As String = "Pain|Pomme|Pomme" Dim cesttrop As String = "Pomme" Dim laplace As Integer = cestlong.LastIndexOf("Pomme") Dim pluscourt As String = cestlong.Substring(0, laplace) Dim EncorePlusCourt As String = cestlong.Substring(0, laplace - 1) MessageBox.Show(pluscourt) MessageBox.Show(EncorePlusCourt) End Sub
Public Sub remFromTable(ByVal file As String, ByVal param As String, ByVal toRem As String) Dim oldStr As String = getParam(file, param) If Not oldStr = String.Empty Then Dim strRemStart As Integer = oldStr.LastIndexOf(toRem) Dim strRemLength As Integer = toRem.Length Dim newStr As String = oldStr.Remove(strRemStart, strRemLength) ' Remove double | newStr = newStr.Replace("||", "|") ' Remove | at the end of th string If Microsoft.VisualBasic.Right(newStr, 1) = "|" Then newStr = Microsoft.VisualBasic.Left(newStr, newStr.Length - 1) End If ' Remove | at the start of the string If Microsoft.VisualBasic.Left(newStr, 1) = "|" Then newStr = Microsoft.VisualBasic.Right(newStr, newStr.Length - 1) End If writeParam(file, param, newStr) End If End Sub
Sub ValeursUniques() Dim ToutesLesValeurs As String = "Séraphin Donalda Séraphin Alexis Ovide Rosa-Rose Alexis Bidou Séraphin Donalda Séraphin Alexis Ovide Rosa-Rose Alexis Bidou" Dim ValeursUniques As New List(Of String) Dim TableauValeurs() As String = Split(ToutesLesValeurs) Dim i As Integer = 0 For Each mot As String In TableauValeurs If Not ValeursUniques.Contains(mot) Then ValeursUniques.Insert(i, mot) i += 1 End If Next Dim ligne As String = String.Empty For Each unmot In ValeursUniques ligne = String.Concat(ligne, ", ", unmot) Next MessageBox.Show(ligne) End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionPrivate Function RemoveDuplicateString() As List(Of String) Dim str1 As String = "pomme|poires|pomme|pain|petit pain|poires" Dim listresult As New List(Of String) Dim splitedstring() As String splitedstring = str1.Split("|"c) For Each item In splitedstring If Not listresult.Contains(item) Then listresult.Add(item) End If Next Return listresult End Function