Solved

Populate Listview from textbox

Posted on 2008-06-18
4
747 Views
Last Modified: 2013-12-25
How can i populate a listview from data in the textbox??

I have a textbox which contains the following :

  _________________
| 1-5, 6-10, 11-15        |

I would like to populate a listbo based on this data entered in the textbox and should be
__________
id | min | max|
1  |   1   |   5
 2  |  6   |   10
 3  |  11 |  1 5

I tried several functions, such as charcount...  but could not come up with a solution. Anyhelp will be appreciated!!
0
Comment
Question by:richammond
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 16

Accepted Solution

by:
Robin earned 300 total points
ID: 21812871
In VB6, you can use this:

    Dim l_sTxt As String
    Dim l_sPc() As String, l_sPm() As String
    Dim l_lIdx As Long
    Dim l_oLi As ListItem
    
    Call ListView1.ListItems.Clear
    
    l_sTxt = Text1.Text
    If l_sTxt <> "" Then
        l_sPc = Split(l_sTxt, ",")
        For l_lIdx = LBound(l_sPc) To UBound(l_sPc)
            Set l_oLi = ListView1.ListItems.Add(, , CStr(l_lIdx + 1))
            l_sPm = Split(Trim(l_sPc(l_lIdx)), "-")
            Call l_oLi.ListSubItems.Add(, , CStr(l_sPm(0)))
            Call l_oLi.ListSubItems.Add(, , CStr(l_sPm(1)))
        Next l_lIdx
    End If

Open in new window

0
 
LVL 53

Assisted Solution

by:Dhaest
Dhaest earned 200 total points
ID: 21812934
So you want to populate your listview with several columns (like http://www.developerfusion.co.uk/show/74/3/?bcsi_scan_165B90ACFD7A1518=eMkQIvd2u6XwTQZRpVb9+QUAAAA0SjQA)

To split your string into small pieces
Dim SplitStr()
SplitStr = Split(myTextbox.text, ",")

in example above you'll get
splitstr(0) = 1-5
splitstr(0) = 6-10
splitstr(0) = 11-15

Dim SplitStr()
SplitStr = Split(myTextbox.text, "-")
 
For intX = 0 To UBound(SplitStr)
   dim smallSplit()
   smallSplit = Split(splitstr(0),",")
   myListbox.listItems.add , ,smallSplit(0)
   myListBox.listItems(i).Subitems(1) = smallsplit(1)
next

Open in new window

0
 
LVL 7

Author Closing Comment

by:richammond
ID: 31468334
Cheers guys!!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
using Access 8 94
How to debug this code 7 65
How to hault or freeze parent form when a 2d form is open in vb6 3 48
Automatic Email Reminder 4 94
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question