как загрузить список строк из файла в ListBox?
Например
*********файл.txt**********
Первая строка
Вторая строка
*************************
Загрузка списка в ListBox
Модератор: Naeel Maqsudov
Наверное, так:
Код: Выделить всё
Application.ScreenUpdating = False
Workbooks.OpenText Filename:="C:\Моя папка\файл.txt"
Dim iStr As Range
For Each iStr In ActiveSheet.UsedRange
UserForm1.ListBox1.RowSource = ""
UserForm1.ListBox1.AddItem iStr.Value
Next
ActiveWorkbook.Close
Application.ScreenUpdating = True
На VB я обычно делаю так
Код: Выделить всё
Dim handle As Integer
Dim theLine As String
Sub FileOpen()
handle = FreeFile
Open "имя файла" For Input As #handle
Do Until EOF(handle)
Line Input #handle, theLine
Text1.Text = Text1.Text & theLine & vbCrLf
'для ListBox просто:
'List1.AddItem(theLine)
Loop
End Sub