Hi, I am very new to programming and have just started to use Visual Basic 2005 Express Edition. I am trying to read from a text file to draw a rectangles and lines. However to begin I'm trying to get the information to show in a listbox so that I know the application is reading the file correctly. I seem to be able to open the file but it doesn't display anything in the listbox.
- Dim FileName As String
-
Dim reader As System.IO.StreamReader
-
-
uieOpenFileDialog.InitialDirectory = "C:\"
-
uieOpenFileDialog.Title = "Open a File"
-
uieOpenFileDialog.Filter = "Text Files(*.txt)|*.txt|All Files(*.*)|*.*"
-
uieOpenFileDialog.ShowDialog()
-
-
MsgBox(FileName)
-
Dim DidWork As Integer = uieOpenFileDialog.ShowDialog()
-
If DidWork = DialogResult.Cancel Then
-
MsgBox("Cancel Button Clicked")
-
Else
-
FileName = uieOpenFileDialog.FileName
-
MsgBox(FileName)
-
End If
-
-
reader = System.IO.File.OpenText(uieOpenFileDialog.FileName)
-
Dim shape As String
-
Dim code As Integer
-
-
Try
-
Me.ListBox1.Items.Clear()
-
-
Do While reader.Peek <> -1
-
shape = reader.ReadLine
-
If shape = "Rectangle" Then
-
Select Case code
-
Case 1
-
-
rect.X = Convert.ToInt32(reader.ReadLine)
-
rect.Y = Convert.ToInt32(reader.ReadLine)
-
rect.Width = Convert.ToInt32(reader.ReadLine)
-
rect.Height = Convert.ToInt32(reader.ReadLine)
-
-
ListBox1.Items.Add()
-
-
-
Case 2
-
rect.X = Convert.ToInt32(reader.ReadLine)
-
rect.Y = Convert.ToInt32(reader.ReadLine)
-
rect.Width = Convert.ToInt32(reader.ReadLine)
-
rect.Height = Convert.ToInt32(reader.ReadLine)
-
-
ListBox1.Items.Add
-
-
End Select
-
Else
-
End If
-
Loop
-
Catch
-
Me.ListBox1.Items.Add("file is empty")
-
End Try
-
reader.Close()
-
End Sub
The error code I'm receiving is: Error 1 Argument not specified for parameter 'item' of 'Public Function Add(item As Object) As Integer'.