Results 1 to 14 of 14

Thread: [RESOLVED] (open) ListView To TextBox

  1. #1

    Thread Starter
    Member bammoeller's Avatar
    Join Date
    Apr 2006
    Posts
    61

    Resolved [RESOLVED] (open) ListView To TextBox

    Hi ! I have a little scanner that scans for certain keywords on my pc when it finds these keywords it adds them to my listbox! So what im wondering is, is it possible to take these keywords that are found and extract them to a textbox?
    Keep in mind i am new at vb6 so this may be stupid question!
    Last edited by bammoeller; Apr 20th, 2006 at 08:40 PM.

  2. #2
    Frenzied Member d3gerald's Avatar
    Join Date
    Jan 2006
    Posts
    1,348

    Re: ListView To TextBox

    well what i think is this is not a stupid question at all rather just one of those sensible ones.

    from which column of the listview will that data come from

    to display from the first column, you can have
    VB Code:
    1. Text1.Text = ListView1.SelectedItem.Text
    2.  
    3. 'to display from the other columns, look at this
    4. Text1.Text = ListView1.ListItems(ListView1.SelectedItem.Index).SubItems.(the column number minus 1)
    On error goto Trap

    Trap:
    in case of emergency, drop the case...

    ****************************************
    If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option.
    if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar

  3. #3

    Thread Starter
    Member bammoeller's Avatar
    Join Date
    Apr 2006
    Posts
    61

    Re: ListView To TextBox

    Here Is My Source
    VB Code:
    1. Private Sub Command1_Click()
    2. Set DGSDirScan1 = New DGSDirScanner
    3. 'regx for word
    4.     Set regx1 = New RegExp
    5.     regx1.Pattern = "[a-zA-Z0-9-_.]+whateverimlookingfor[a-zA-Z0-9-_.]+\.[a-zA-Z0-9]+"   ' Set pattern.
    6.     regx1.IgnoreCase = False   ' Set case insensitivity.
    7.     regx1.Global = True        ' Set global applicability.
    8. If Me.lblscanfoldertarget & "" = "" Then
    9.     MsgBox "Please select a folder to scan", vbOKOnly, "Nothing to do"
    10.     Exit Sub
    11. End If
    12.  
    13. ' make sure folder exist
    14. Dim fs As FileSystemObject
    15. Set fs = New FileSystemObject
    16. If fs.FolderExists(Me.lblscanfoldertarget) = False Then
    17.     MsgBox "The folder you selected does not exist!", vbCritical, "Error"
    18.     Exit Sub
    19. End If
    20.  
    21. ' create a dictionary object and add all the extensions to be scanned
    22. Set extensions = New Dictionary
    23. Dim a As Long
    24. extensions.RemoveAll
    25. For a = 0 To lstExt.ListCount - 1
    26.     extensions.Add lstExt.List(a), lstExt.List(a)
    27. Next
    28.  
    29.  
    30. ' Start recursive directory scan
    31. ' Fires the new folder and new file event (below) for every file/folder
    32. DGSDirScan1.Scan Me.lblscanfoldertarget
    33.  
    34.  
    35. End Sub
    36.  
    37. Private Sub DGSDirScan1_newfile(f As Scripting.IFile)
    38. Dim ext As String
    39. ext = Right(f.path, 4)
    40. If extensions.Exists(ext) = True Then
    41.    
    42.     Me.RTF1.LoadFile f.path
    43.     ExtractEmail f.path
    44. End If
    45. End Sub
    46. Private Sub Extractword(path As String)
    47.         On Error Resume Next
    48.        
    49.         Set Matches = regx1.Execute(RTF1.Text)
    50.         For Each Match In Matches
    51.          
    52.             Me.ListView1.ListItems.Add , Match.Value, Match.Value
    53.             Me.ListView1.ListItems(Match.Value).ListSubItems.Add , Match.Value, path
    54.   Next
    55.        
    56. End Sub
    57.  
    58. Private Sub ListView1_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
    59. If ListView1.SortKey = ColumnHeader.Index - 1 Then
    60.     If ListView1.SortOrder = lvwAscending Then
    61.         ListView1.SortOrder = lvwDescending
    62.     Else
    63.         ListView1.SortOrder = lvwAscending
    64.     End If
    65. Else
    66.     ListView1.SortOrder = lvwAscending
    67.     ListView1.SortKey = ColumnHeader.Index - 1
    68. End If
    69. ListView1.Sorted = True
    70. End

  4. #4
    Frenzied Member d3gerald's Avatar
    Join Date
    Jan 2006
    Posts
    1,348

    Re: ListView To TextBox

    i dont see any code that displays text from listview to textbox

    use my suggestion in post no 2 and use the click event of the listview to do it
    On error goto Trap

    Trap:
    in case of emergency, drop the case...

    ****************************************
    If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option.
    if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar

  5. #5

    Thread Starter
    Member bammoeller's Avatar
    Join Date
    Apr 2006
    Posts
    61

    Re: ListView To TextBox

    Great deal this line works
    Text1.Text = ListView1.SelectedItem.Text
    like i was saying im kinda new and maby this source has already been posted! But what im wondering now is how do i add all the objects on the list instead of just the first one?
    Thanks Bro you have been a large help so far!!!
    it looks like this is the source that will allow me to do that
    Text1.Text = ListView1.ListItems(ListView1.SelectedItem.Index).SubItems.(the column number minus 1)
    but i get an error identified or braketed expression
    Last edited by bammoeller; Apr 20th, 2006 at 06:33 PM.

  6. #6
    Member
    Join Date
    Apr 2005
    Posts
    38

    Thumbs up Re: ListView To TextBox

    There shouldn't be a full-stop before the brackets. Hence:

    VB Code:
    1. Text1.Text = ListView1.ListItems(ListView1.SelectedItem.Index).SubItems(the column number minus 1)
    Then I imagine you have to repeat that for each of the text boxes.

  7. #7

    Thread Starter
    Member bammoeller's Avatar
    Join Date
    Apr 2006
    Posts
    61

    Re: ListView To TextBox

    actually let me ask this! This is what i have
    Private Sub Command2_Click()
    txtSendTo = ListView1.SelectedItem.Text
    End Sub
    as soon as i click the command button it loads the first item found in the listbox to the text box!!
    would it be possible to make it where everytime you click the command button it will automaticly drop down to the next listitem and add it to the textbox?

  8. #8
    Frenzied Member d3gerald's Avatar
    Join Date
    Jan 2006
    Posts
    1,348

    Re: ListView To TextBox

    maybe this is what you want
    VB Code:
    1. Private Sub Command1_Click()
    2.     If ListView1.SelectedItem.Index < ListView1.ListItems.Count Then
    3.         ListView1.SelectedItem = ListView1.ListItems(ListView1.SelectedItem.Index + 1)
    4.     Else
    5.         ListView1.SelectedItem = ListView1.ListItems(1)
    6.     End If
    7.    
    8.     'then chose what you want from the following codes
    9.     'to display the selected item in the listview to the textbox
    10.     Text1.Text = ListView1.SelectedItem.Text
    11.     'to add or concatenate the selected value to the value in the textbox, use this
    12.     Text1.Text = Text1.Text & ListView1.SelectedItem.Text
    13. End Sub
    On error goto Trap

    Trap:
    in case of emergency, drop the case...

    ****************************************
    If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option.
    if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar

  9. #9

    Thread Starter
    Member bammoeller's Avatar
    Join Date
    Apr 2006
    Posts
    61

    Smile Re: ListView To TextBox

    Thanks you so much you are the man!!!!!!!!!!!!!!!!!!!!!

  10. #10
    Frenzied Member d3gerald's Avatar
    Join Date
    Jan 2006
    Posts
    1,348

    Re: (Resolved) ListView To TextBox

    well, can you then please mark this thread as resolved. look at my signature below this message for instructions ok
    On error goto Trap

    Trap:
    in case of emergency, drop the case...

    ****************************************
    If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option.
    if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar

  11. #11
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,175

    Re: (Resolved) ListView To TextBox

    Thanks for letting us know that you have your answer but the easy way to do that is by pulling down the Thread Tools menu and clicking the Mark Thread Resolved button. Also if someone has been particularly helpful, or even particularly unhelpful, you have the ability to affect a their forum "reputation" by rating their post.

  12. #12

    Thread Starter
    Member bammoeller's Avatar
    Join Date
    Apr 2006
    Posts
    61

    Re: (open) ListView To TextBox

    Sorry to bug you again the last code works fine besides it double post objects into the textbox. lets say i am scanning emails! it will look like this in the textbox
    name@whatever.comname@whatever.com

  13. #13

    Thread Starter
    Member bammoeller's Avatar
    Join Date
    Apr 2006
    Posts
    61

    Re: (open) ListView To TextBox

    Nevermind Thanks!!!!!

  14. #14
    Frenzied Member d3gerald's Avatar
    Join Date
    Jan 2006
    Posts
    1,348

    Re: [RESOLVED] (open) ListView To TextBox

    do this
    VB Code:
    1. Private Sub Command1_Click()
    2.     If ListView1.SelectedItem.Index < ListView1.ListItems.Count Then
    3.         ListView1.SelectedItem = ListView1.ListItems(ListView1.SelectedItem.Index + 1)
    4.     Else
    5.         ListView1.SelectedItem = ListView1.ListItems(1)
    6.     End If
    7.      'ok if you want to replace the value displayed in the textbox
    8.     Text1.Text = ListView1.SelectedItem.Text
    9. End Sub
    On error goto Trap

    Trap:
    in case of emergency, drop the case...

    ****************************************
    If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option.
    if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width