none
Add progress bar in VB 2010 Express. RRS feed

  • Question

  • I wrote a program about five years ago that encrypts text.  The program works as intended, but being old (76) I cannot remember/get a progress bar to work as the text is being processed through encryption.  Button3 on Form3 makes the call for encryption.   I have commented out my attempt at a progress bar inasmuch as it did not work anyway.

       

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click 

          Dim Source As String = TextBox1.Text       

    Dim fileReader As String       

    Label3.Visible = True  '**********Encrypting text...this will take awhile.***************       

    Me.Refresh()       

    'Call the  Encrypt function Encrypt and pass it the Source varible.         

    Call Encrypt(Source)       

    'Private Sub ProgressBar1_Click(sender As System.Object, e As System.EventArgs) Handles ProgressBar1.Click 

    '   Dim i As Integer       

    '   ProgressBar1.Minimum = 0       

    '   Sets the Maximum for the progress bar to the lenght of the of the combined string (NumerOf).       

    '   ProgressBar1.Maximum = NumberOf       

    '       For i = 0 To NumberOf       

    '           ProgressBar1.Value = i       

    '       Next        'End Sub       

    '*************************************************       

    'Reads encrypted from disk file into Form3 Text Box 2.       

    fileReader = My.Computer.FileSystem.ReadAllText(strWholePathVar)       

    Me.TextBox2.Text = (fileReader)       

    Label3.Text = "Encryption complete."   

    End Sub   

    End Class

    Someone could please give me a tip in how to display code?  If I cut it from my code editor and past it here with code tags around it, it puts it all on one line.

    Tuesday, December 3, 2019 10:08 PM

All replies

  • Someone could please give me a tip in how to display code?  If I cut it from my code editor and past it here with code tags around it, it puts it all on one line.

    Hi

    To post code, use the code block tool from the toolbar, choose VB.NET in the drop down, copy/paste direct from the VB edit window and submit (review if needed)

    *

    As for your question. You did not show the encryption code, and it is likely that that is where you would need to add the Progress Bar code.

    On the other hand, if the encryption code is in a module, then extra work would be needed - such as a call back to parent Form code with updated counter from within the encryption code loop (my assumption that there is a loop). All that is assuming you are encrypting/decrypting large files and in 'chunks'.

    So, you should probably post the encryption code.


    Regards Les, Livingston, Scotland


    • Edited by leshay Tuesday, December 3, 2019 11:26 PM
    Tuesday, December 3, 2019 10:44 PM