Pergunta

I am using VS 2010, code in VB.net. For whatever reason, my Form1.Load (in my app, its called Form.JNA) wont run. It simply wont execute any of the code in that subroutine. Does anyone know why this is occurring?

My main form is called FormJNA. I dont know if including the beginning of the code helps, so here it is. I know its not working because boolConfirmed is never true and the textReqDate textbox is empty.

Private Sub FormJNA_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

        'Close the database in case it was left open
        All.rstRecordSet.Close()
        All.conConnection.Close()

        strEmailServer = All.GetEmailServer("tblEmailServer", "Server")  'retrieves the email name from JNADB

        boolConfirmed = True  'set as true since there is no data to be confirmed. this prevents a popup window warning the user of unconfirmed data

        'For live date in application window
        Timer1.Start()
        txtReqDate.Text = DateValue(Now)
....
...
..
.

When I insert a breakpoint I put it on that first comment line of code. When I run the program, it takes me to the breakpoint and there is that yellow arrow over the red dot. I press the button to move the arrow and the window opens, but then the yellow arrow disappears and I cant move anywhere further in the program unless I push one of the buttons on the main form. All of the other forms work and run just fine except for this one.

Foi útil?

Solução

Your code is probably throwing an error that is not being reported.

Try wrapping everything with a Try Catch Block and see what the exception is

Outras dicas

You are probably stepping into a routine that is taking a long time to complete.. or infinitely looping and never returning. The form never shows, because the form_load possibly does not complete, or takes a long time to complete and you close the app before the form loads.

Solved the problem. That All.GetEmailServer function opened up an Access DB but never closed it, which caused an error when a function lower in the Load sub was called that opened an Access DB using the same connection string.

Thanks Matt Wilko, couldnt have found it without the try catch block!

Try using the form Shown() event instead of Load event

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top