I'm declaring a line at the top of my code window.

Dim sTemp as String = textbox1.text

I have no idea why. I tried commenting a few things related to the code but none of it makes it work.

Any ideas?

Member Avatar

If your code looks like this then

Public Class Form1
   Dim sTemp as String = textbox1.text
End Class

The text box has not been created yet. Move the line into the Constructor or Load Event

Public Class Form1
    Private sTemp As String

    Sub New()

        ' This call is required by the Windows Form Designer.

        ' Add any initialization after the InitializeComponent() call.
        sTemp = TextBox1.Text
    End Sub

End Class

Thanks! Did the trick!