Solved

Load items to list view is nto working ;(

Posted on 2004-08-16
4
166 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
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 50

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

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.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

815 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

12 Experts available now in Live!

Get 1:1 Help Now