Form1 Error

Posts 1–15 of 21 · Page 1 of 2
Form1 Error
I am so confused right now.. I am working on a project, and I need form1 to start, but not show. It has been working just fine, until randomly it gives me this error



I have done NOTHING to form1, I can still edit it and whatnot, but when I try to debug it with form1 as the starting form, the same error occurs.



I don't understand since I have done nothing to form1 before that error occurred. Can any one explain why this is coming up and how to fix it? Thanks.
You can't in same time HIDE and SHOW FORM1, do Form1.Show() and ' Form1.hide() and try then
Quote Originally Posted by Trle94 View Post
You can't in same time HIDE and SHOW FORM1, do Form1.Show() and ' Form1.hide() and try then
Uhh.. I've been doing this for the longest time now... It has been working ever since. I don't believe that is the problem.
Explain what you want to do. You want to let form1 be shown and then immediately hide?
Quote Originally Posted by alaska321 View Post
Explain what you want to do. You want to let form1 be shown and then immediately hide?
No. I want it to be started so I can use Form1's Notify Icon, instead of adding another. (but I don't want to show form1 yet)

But as I've said before, I'm 99% sure that's not the problem. Even when I try to use Form1 as the starting form, this error still occurs.
that happened to me when i used themes for app
That error looks firmiliar. Have you recently created any new variables at the top of the form? Probably a custom class object, and you used the new operator?

Dim myBigObject As New SomeBigClass

maybe? I've had that happen to me before, maybe something about the order in which objects/forms are created (circular referencing/dependencies?)
Quote Originally Posted by abuckau907 View Post
That error looks firmiliar. Have you recently created any new variables at the top of the form? Probably a custom class object, and you used the new operator?

Dim myBigObject As New SomeBigClass

maybe? I've had that happen to me before, maybe something about the order in which objects/forms are created (circular referencing/dependencies?)
Yeah, I did. I changed it back, and it's working. But why does this happen? I was just trying to clean up my code...

EDIT: I even changed the order around, but I still got the same error.
To be honest, idk. Something about using the new, and actually creating the object, causes the error. Maybe something about the constructor of the object being called before __________. Maybe someone else can comment.

Maybe post the code of said class? Did you write a custom constructor? Does said class 'refer' to Form1 / it's objects?

-an easy fix is to leave the declaration at the top of the form class, without* the new keyword.
. and in form_load, set the object = new itsClass()
Quote Originally Posted by abuckau907 View Post
To be honest, idk. Something about using the new, and actually creating the object, causes the error. Maybe something about the constructor of the object being called before __________. Maybe someone else can comment.

Maybe post the code of said class? Did you write a custom constructor? Does said class 'refer' to Form1 / it's objects?
All I have under 'Public Class Form1' was 'GetAsyncKeyState' for hotkeys and whatnot.

Code:
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vbkey As Int16) As Int32
But, I am using this code here in a few subs, so I thought I would put it at the top

Code:
Dim Status As String = GetPageSource("somewebsite" + TextBox1.Text + ".html")
But the thing is, I'm not using the 'New' function...
"..Form1 / it's objects"
Code:
Dim Status As String = GetPageSource("somewebsite" + TextBox1.Text + ".html")
My guess is TextBox1 hasn't been created yet, when that code runs. Declare the variable at the top, assign it in form_load. Cheezy, but works. Scenario is kind of suspect tbh.

I think..
Code:
// Form1 is actually a 'class'
// It's members (variables) are allocated before it's constructor is called
// It's constructor is what actually sets TextBox1 = new TextBox()
// So since your orig. code was creating a variable inside the Form1 class (before the form1 constructor has been called)
// AND assigning it: TextBox1 hasn't been created (and initialized) yet. Hence error: TextBox1.Text doesn't exist (yet).
// or something like that
Ohhh.. so you're saying that when the form loads, it hasn't loaded textbox1 and then it causes that error?

And what do you mean by suspect? o.o
Kind of, I guess.
I'm saying, when you declare variables in a class...they are allocated (space made in ram) before the constructor of the class runs.
Since your variable was declared inside the class, it's being allocated before Form1's constructor gets called.
Until Form1's constructor is called, none of the controls (Labels, txtBoxes, etc) on the form have been created.

Your variable 'Status' tries to use TextBox1 before it's been created (ie. before the form1 constructor has run). Error.

----
computer.filesystem.delete in the first screenshot.
Getasynckeys.
DL() / Clean() subs. -Download / clean ?
Making the form hide itsself on start up.

the class 'haz only basic codez' but you didn't paste it. Must be secretive code. :/ - imo. I've been known to be wrong.
This is an auto updater form. It downloads a verstion.txt and reads it. The Clean is for deleting files that are used in the update process.

As for the hiding it's self, I said before, I'm using it's notify icon.
@master131 helped me with the 'get page source' for a CBL Checker project.
auto-updating is evidence against you imo :/ o well, issue resolved. happy hacking.

edit: I'm sure you "didn't mean 'auto'", you mean on button_click etc etc. idc. Prove me wrong with a release soon.
Posts 1–15 of 21 · Page 1 of 2

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us