Results 1 to 5 of 5

Thread: [2005] Progress bar doesnt increment or get an error

  1. #1

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

    [2005] Progress bar doesnt increment or get an error

    I am using my encryption class from MSDN which has worked so far until this point. The code is below and I either get an error where the DecodeText() part is right now or if I put it in the other areas for the file name, I get no errors but the progress bar doesn't move (line 5 or line 27). Any ideas?
    vb Code:
    1. Imports Cryptography.clsCrypto
    2.  
    3. Public Class frmSQLExecuteProgress
    4.     'specify the location of the dbu file
    5.     Dim strFileLocation As String = My.Application.Info.DirectoryPath & "\sql\sql.dbu"
    6.  
    7.     Private Sub frmSQLExecuteProgress_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    8.         'form layout
    9.         FormLayout(Me)
    10.  
    11.         'start the timer
    12.         With tmrProgBar
    13.             .Enabled = True
    14.             .Interval = 7000
    15.             .Start()
    16.         End With
    17.     End Sub
    18.  
    19.     Private Sub cmdDone_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDone.Click
    20.         'when the done button is clicked on, close the form
    21.         Me.Close()
    22.     End Sub
    23.  
    24.     Private Sub tmrProgBar_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrProgBar.Tick
    25.         With (My.Computer.FileSystem)
    26.             'lets see if the file exists
    27.             If System.IO.File.Exists(strFileLocation) Then
    28.                 'read all the lines in the file
    29.                 Dim arrDBULineCount() As String = IO.File.ReadAllLines(DecodeText(strFileLocation))
    30.  
    31.                 With prgDatabaseExecution
    32.                     'set the minimum to 0%
    33.                     .Minimum = 0
    34.                     'set the maximum to 100%
    35.                     .Maximum = 100
    36.                     'give step the value of the number of lines in the dbu file
    37.                     .Step = CInt(arrDBULineCount.Length.ToString)
    38.                     'get the incremental by dividing the line count by 100
    39.                     .Value = CInt(.Step / .Maximum)
    40.                     'start the progress bar
    41.                     .PerformStep()
    42.  
    43.                     If .Value = 100 Then
    44.                         'now that the request has been completed, delete the file
    45.                         IO.File.Delete(strFileLocation)
    46.  
    47.                         With tmrProgBar
    48.                             .Stop()
    49.                             .Enabled = False
    50.  
    51.                             'resize the form
    52.                             With Me
    53.                                 .Height = 110
    54.                                 .Width = 300
    55.                             End With
    56.  
    57.                             'show the done button
    58.                             cmdDone.Visible = True
    59.                         End With
    60.                     End If
    61.                 End With
    62.             End If
    63.         End With
    64.     End Sub
    65. End Class
    error is
    An unhandled error has occurred in the application and the error log is attached for resolution assignment.

    Message:
    Illegal characters in path.

    Stack trace:
    at System.IO.Path.CheckInvalidPathChars(String path)
    at System.IO.Path.GetFileName(String path)
    at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
    at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize)
    at System.IO.StreamReader..ctor(String path, Encoding encoding)
    at System.IO.File.ReadAllLines(String path, Encoding encoding)
    at System.IO.File.ReadAllLines(String path)
    at BusinessStudio.frmSQLExecuteProgress.tmrProgBar_Tick(Object sender, EventArgs e) in D:\BusinessStudio\frmSQLExecuteProgress.vb:line 29
    at System.Windows.Forms.Timer.OnTick(EventArgs e)
    at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
    at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

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

    Re: [2005] Progress bar doesnt increment or get an error

    I would suggest that this line:
    vb.net Code:
    1. Dim arrDBULineCount() As String = IO.File.ReadAllLines(DecodeText(strFileLocation))
    is quite wrong. Presumably DecodeText opens the file, reads the contents, decrypts it and returns the result. ReadAllLines expects a file path and, if my assumption is correct then what you're passing to it is definitely not a file path.

    As for the ProgressBar "not working" you probably have to call its Refresh method to force it to repaint because your thread is too busy working to update the UI.

  3. #3
    Frenzied Member Icyculyr's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    1,934

    Re: [2005] Progress bar doesnt increment or get an error

    I've found Application.DoEvents() does the trick for me (showing progress bar progress).

    Cheers
    Icyculyr

  4. #4

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

    Re: [2005] Progress bar doesnt increment or get an error

    Quote Originally Posted by jmcilhinney
    I would suggest that this line:
    vb.net Code:
    1. Dim arrDBULineCount() As String = IO.File.ReadAllLines(DecodeText(strFileLocation))
    is quite wrong. Presumably DecodeText opens the file, reads the contents, decrypts it and returns the result. ReadAllLines expects a file path and, if my assumption is correct then what you're passing to it is definitely not a file path.

    As for the ProgressBar "not working" you probably have to call its Refresh method to force it to repaint because your thread is too busy working to update the UI.
    ive tried using the .refresh and the progress bar still isnt incrementing. also tried application.doevents and still doesnt do anything so far. still trying to debug this thing. thanks for the suggestions.

  5. #5

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

    Re: [2005] Progress bar doesnt increment or get an error

    i even did a messagebox and the text file is being decrypted as the content of the file views in the messagebox. only thing is, its not getting the lines of code in teh decrypted file and then incrementing the progressbar. hm.
    vb Code:
    1. Imports Cryptography.clsCrypto
    2.  
    3. Public Class frmSQLExecuteProgress
    4.     'specify the location of the dbu file
    5.     Dim strFileLocation As String = My.Application.Info.DirectoryPath & "\sql\sql.dbu"
    6.     Private Sub frmSQLExecuteProgress_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    7.         'form layout
    8.         FormLayout(Me)
    9.  
    10.         'decode the text content
    11.         DecodeText(strFileLocation)
    12.  
    13.         MessageBox.Show(DecodeText(strFileLocation))
    14.  
    15.         'start the timer
    16.         With tmrProgBar
    17.             .Enabled = True
    18.             .Interval = 7000
    19.             .Start()
    20.         End With
    21.     End Sub
    22.  
    23.     Private Sub cmdDone_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDone.Click
    24.         'when the done button is clicked on, close the form
    25.         Me.Close()
    26.     End Sub
    27.  
    28.     Private Sub tmrProgBar_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrProgBar.Tick
    29.         With (My.Computer.FileSystem)
    30.             'lets see if the file exists
    31.             If System.IO.File.Exists(strFileLocation) Then
    32.                 'read all the lines in the file
    33.                 Dim arrDBULineCount() As String = IO.File.ReadAllLines(strFileLocation)
    34.  
    35.                 With prgDatabaseExecution
    36.                     'set the minimum to 0%
    37.                     .Minimum = 0
    38.                     'set the maximum to 100%
    39.                     .Maximum = 100
    40.                     'give step the value of the number of lines in the dbu file
    41.                     .Step = CInt(arrDBULineCount.Length.ToString)
    42.                     'get the incremental by dividing the line count by 100
    43.                     .Value = CInt(.Step / .Maximum)
    44.                     'start the progress bar
    45.                     .PerformStep()
    46.                     'refresh the progress bar
    47.                     '.Refresh()
    48.                     Application.DoEvents()
    49.  
    50.                     If .Value = 100 Then
    51.                         'now that the request has been completed, delete the file
    52.                         IO.File.Delete(strFileLocation)
    53.  
    54.                         With tmrProgBar
    55.                             .Stop()
    56.                             .Enabled = False
    57.  
    58.                             'resize the form
    59.                             With Me
    60.                                 .Height = 110
    61.                                 .Width = 300
    62.                             End With
    63.  
    64.                             'show the done button
    65.                             cmdDone.Visible = True
    66.                         End With
    67.                     End If
    68.                 End With
    69.             End If
    70.         End With
    71.     End Sub
    72. End Class

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