Results 1 to 4 of 4

Thread: [RESOLVED] [2005] Value Close() cannot be called while doing CreateHandle()

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Resolved [RESOLVED] [2005] Value Close() cannot be called while doing CreateHandle()

    my database table creation works. now i have added a form with a progress bar when this is going through and now get an error when trying to close the form after the sql file has been successfully deleted.
    ------------------------------Start Of Error------------------------------
    Error Occurred On:
    5/3/2008 12:31:40 PM

    Data:
    System.Collections.ListDictionaryInternal

    Message:
    Value Close() cannot be called while doing CreateHandle().

    Stack Trace:
    at System.Windows.Forms.Form.Close()
    at BusinessStudio.frmSQLExecuteProgress.frmSQLExecuteProgress_Load(Object sender, EventArgs e) in D:\BusinessStudio\frmSQLExecuteProgress.vb:line 36
    at System.Windows.Forms.Form.OnLoad(EventArgs e)
    at System.Windows.Forms.Form.OnCreateControl()
    at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
    at System.Windows.Forms.Control.CreateControl()
    at System.Windows.Forms.Control.WmShowWindow(Message& m)
    at System.Windows.Forms.Control.WndProc(Message& m)
    at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
    at System.Windows.Forms.ContainerControl.WndProc(Message& m)
    at System.Windows.Forms.Form.WmShowWindow(Message& m)
    at System.Windows.Forms.Form.WndProc(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
    at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    ------------------------------ End Of Error ------------------------------
    vb Code:
    1. Public Class frmSQLExecuteProgress
    2.     Private Sub frmSQLExecuteProgress_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    3.         'form layout
    4.         FormLayout(Me)
    5.  
    6.         'specify the location of the dbu file
    7.         Dim strFileLocation As String = My.Application.Info.DirectoryPath & "\sql\sql.dbu"
    8.  
    9.         With (My.Computer.FileSystem)
    10.             'lets see if the file exists
    11.             If System.IO.File.Exists(strFileLocation) Then
    12.                 'read all the lines in the file
    13.                 Dim arrDBULineCount() As String = IO.File.ReadAllLines(strFileLocation)
    14.  
    15.                 With prgDatabaseExecution
    16.                     'set the minimum to 0%
    17.                     .Minimum = 0
    18.                     'set the maximum to 100%
    19.                     .Maximum = 100
    20.                     'give step the value of the number of lines in the dbu file
    21.                     .Step = CInt(arrDBULineCount.Length.ToString)
    22.                     'get the incremental by dividing the line count by 100
    23.                     .Value = CInt(.Step / .Maximum)
    24.                     'start the progress bar
    25.                     .PerformStep()
    26.  
    27.                     If .Value = 100 Then
    28.                         'now that the request has been completed, delete the file
    29.                         IO.File.Delete(strFileLocation)
    30.                         'close this screen
    31.                     End If
    32.                 End With
    33.             End If
    34.         End With
    35.  
    36.         Me.Close()
    37.     End Sub
    38. End Class
    been working at this for a few hours and not sure what to do

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] Value Close() cannot be called while doing CreateHandle()

    You're calling Close on a form in its Load event handler. That's a no-no. Why would you do that? If you don't want the form open then why show it in the first place?
    Last edited by jmcilhinney; May 3rd, 2008 at 11:47 AM.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: [2005] Value Close() cannot be called while doing CreateHandle()

    Quote Originally Posted by jmcilhinney
    You're calling Close on a form in its Load event handler. That's a no-no. Why would you do that? If you don't want the form open then why show it in the first place?
    oh my, i didnt even notice that! thanks jc

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: [2005] Value Close() cannot be called while doing CreateHandle()

    ok, added a button and using that to close the form. not thinking straight today it looks like

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width