Solved

Load items to list view is nto working ;(

Posted on 2004-08-16
4
168 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
[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
  • 2
4 Comments
 
LVL 4

Expert Comment

by:cachedVB
ID: 11817120
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
ID: 11817161
does this work for list view?
0
 

Author Comment

by:andyakira
ID: 11817195
i cant get it to work, i need one for listview.
0
 
LVL 51

Accepted Solution

by:
Ryan Chong earned 350 total points
ID: 11817518
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

Technology Partners: 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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…

696 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