我正在写一个简单的应用程序来读取文本框的值并添加到列表框控件。但我必须通过列表框控件才能运行。任何建议?如何将ListBox控件的所有值传递给函数?
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
test("E:\Satyajit.txt")
End Sub
Public Function test(ByVal filename As String)
Dim FILE_NAME As String = filename
Dim TextLine As String
Dim result As String = Path.GetFileName(FILE_NAME)
Dim objReader As New System.IO.StreamReader(FILE_NAME)
Do While objReader.Peek() <> -1
TextLine = objReader.ReadLine()
words = TextLine.Split(New Char() {","c})
ListBox1.Items.Add(words(3) & "," & words(4))
objItem = ListView1.Items.Add(words(3) & "," & words(4))
Loop
test1(ListBox1.Items)//pass the listbox value hare
End Function
Public Function test1(ByVal value As String)
Dim Fest As String = value
MsgBox(Fest)
End Function
你想通过它所有列表框的ems?还是只有1? – missellorin
列表框中所选项目的值? – Fred
我不确定你在问什么。或许:1)'公共函数test1(ByVal items As ListBox.ObjectCollection)...',2)'test1(ListBox1.Items)'? – paulsm4