Solved

Load items to list view is nto working ;(

Posted on 2004-08-16
4
169 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 52

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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 process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

734 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