VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



list to text, text to list: puts a string using separation-strings into a listbox or combobox (exam

by Rabbit (2 Submissions)
Category: String Manipulation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Wed 18th June 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)

list to text, text to list: puts a string using separation-strings into a listbox or combobox (example: "pie.and.cake" => sepstring = ".")

Rate list to text, text to list: puts a string using separation-strings into a listbox or combobox (exam



Dim I
Dim StartListIndex
StartListIndex = ListOrCombo.ListIndex
For I = 0 To ListOrCombo.ListCount - 1
If (I > 0) Then ListToText = ListToText + SepString
ListOrCombo.ListIndex = I
ListToText = ListToText + ListOrCombo.Text
DoEvents
Next
ListOrCombo.ListIndex = StartListIndex
End Function

Public Function TextToList(SourceString As String, ListOrCombo As Object, SepString As String, ClearList As Boolean)
Dim I
Dim ii
If (ClearList = True) Then ListOrCombo.Clear
ii = 1
For I = 1 To Len(SourceString)
If (Mid(SourceString, I, Len(SepString)) = SepString) Then
ListOrCombo.AddItem Mid(SourceString, ii, I - ii)
ii = I + Len(SepString)
End If
If (I = Len(SourceString)) Then ListOrCombo.AddItem Mid(SourceString, ii, I - ii + 1)
DoEvents
Next
End Function

Public Function DblTextToList(SourceString As String, ListOrCombo As Object, SepString As String, SecSepString, ClearList As Boolean) 'for example, ', ' and ' & ' in the sentence apple, pie & cake
Dim I
Dim ii
If (ClearList = True) Then ListOrCombo.Clear
ii = 1
For I = 1 To Len(SourceString)
If (Mid(SourceString, I, Len(SepString)) = SepString) Then
ListOrCombo.AddItem Mid(SourceString, ii, I - ii)
ii = I + Len(SepString)
ElseIf (Mid(SourceString, I, Len(SecSepString)) = SecSepString) Then
ListOrCombo.AddItem Mid(SourceString, ii, I - ii)
ii = I + Len(SecSepString)
End If
If (I = Len(SourceString)) Then ListOrCombo.AddItem Mid(SourceString, ii, I - ii + 1)
DoEvents
Next
End Function

Download this snippet    Add to My Saved Code

list to text, text to list: puts a string using separation-strings into a listbox or combobox (exam Comments

No comments have been posted about list to text, text to list: puts a string using separation-strings into a listbox or combobox (exam. Why not be the first to post a comment about list to text, text to list: puts a string using separation-strings into a listbox or combobox (exam.

Post your comment

Subject:
Message:
0/1000 characters