Sign in to follow this  
Kryptus

VB.NET error

Recommended Posts

Kryptus    100
I have made a simple notepad program in VB.NET and I have created the textbox control manually using the new textbox syntax. My intention is to make a simple notepad with tabs. In global declarations I created the array as:
Public MyTextBox(255) As TextBox

I created the control in my form's Load event, so the code is as below:
MyTextBox(0) = New TextBox
MyTextBox(0).Multiline = True
MyTextBox(0).Location = New Point(40, 40)
MyTextBox(0).Size = New Size(400, 300)
Controls.AddRange(New Control() {MyTextBox(0)})
frmMain_Resize(sender, e)

Then in the resize code I have:
MyTextBox(0).Left = 0
MyTextBox(0).Top = 0
MyTextBox(0).Width = Me.Width
MyTextBox(0).Height = Me.Height

I get the following error: InvalidOperationException was unhandled An error occurred creating the form. See Exception.InnerException for details. The error is: Object reference not set to an instance of an object. How do I fix this? I don't even know what is going on! Thanks.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this