Solved

Load items to list view is nto working ;(

Posted on 2004-08-16
4
163 Views
Last Modified: 2010-05-02


Public Function FLoadlistV(file$, listx As ListView) As String
Dim x As String
    Dim sLineIn As String
    On Error GoTo ErrLoadListFromFile
 
    listx.ListItems.Clear
    Open file$ For Input As #1
    While Not EOF(1)
        Line Input #1, sLineIn
        x = Replace(Trim$(sLineIn), " ", "")
        If x <> "" Then listx.ListItems.Add sLineIn
    Wend
   
ErrLoadListFromFile:
    Close #1
End Function

if this right i call it like this:   Call FLoadlistV(App.Path & "\phrase.txt", phrase)
there is no errors, it just is not loading into the list.
0
Comment
Question by:andyakira
  • 2
4 Comments
 
LVL 4

Expert Comment

by:cachedVB
Comment Utility
Public Function LoadListFromFile(ByRef SourceFile As String, _
     ByRef List As ListBox)
On Error GoTo ErrEvt
Dim TextLine As String, FN As Integer

List.Clear

FN = FreeFile
 Open SourceFile For Input As #FN ' Open file.
   Do While Not EOF(FN) ' Loop until end of file.
   Line Input #FN, TextLine ' Read line into variable.
   If TextLine <> LineToRem Then
    List.AddItem (TextLine)
    Else
    If X > 9999999 Then
    MsgBox "Error!"
    Exit Function
    End If
   
   End If
Loop
Close #FN ' Close file.



ErrEvt:
Select Case Err.number
   Case 51
      Err.Clear
   Case Else
   X = X + 1
End Select

Resume Next
End Function



try that instead
0
 

Author Comment

by:andyakira
Comment Utility
does this work for list view?
0
 

Author Comment

by:andyakira
Comment Utility
i cant get it to work, i need one for listview.
0
 
LVL 49

Accepted Solution

by:
Ryan Chong earned 350 total points
Comment Utility
Try:

Public Function FLoadlistV(file$, listx As ListView) As String
    Dim x As String
    Dim sLineIn As String
    'On Error GoTo ErrLoadListFromFile
 
    listx.ListItems.Clear
    Open file$ For Input As #1
    While Not EOF(1)
        Line Input #1, sLineIn
        x = Replace(Trim$(sLineIn), " ", "")
        If x <> "" Then listx.ListItems.Add , , sLineIn
    Wend
   
ErrLoadListFromFile:
    Close #1
End Function

>>listx.ListItems.Add sLineIn
Should changed to listx.ListItems.Add , , sLineIn

cheers
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now