Click here to Skip to main content
15,617,116 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a progress bar on Form1 and a button on Form2 .When I click that button , the progress bar value should change in a Timer event which is created on Form2 .After creating the timer I called a function from C dll in that button click .Can u tell me what's the wrong in code. The code is as follows

Sub THandler()
        If Net_mang_Form.Prg_bar.Value = 100 Then
            Net_mang_Form.Prg_bar.Value = 10
 End Sub

Private Sub uplod_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles uplod_btn.Click

       If Net_mang_Form.dev_nm Is Nothing OrElse Net_mang_Form.dev_nm.Trim = "" Then
           Dim MyFolderBrowser As New System.Windows.Forms.FolderBrowserDialog

           ' Descriptive text displayed above the tree view control in the dialog box
           MyFolderBrowser.Description = "Select the Folder"

           ' Sets the root folder where the browsing starts from
           'MyFolderBrowser.RootFolder = Environment.SpecialFolder.MyDocuments

           ' Do not show the button for new folder
           MyFolderBrowser.ShowNewFolderButton = False

           Dim dlgResult As DialogResult = MyFolderBrowser.ShowDialog()

           If dlgResult = Windows.Forms.DialogResult.OK Then
               Net_mang_Form.snd_file_path = MyFolderBrowser.SelectedPath
               Net_mang_Form.snd_file_path = String.Concat(Net_mang_Form.snd_file_path, "\")
               MsgBox("Choose Upload File path before Continue..")
               Exit Sub
           End If

       End If

       '=================== Upload Process is going on =====================
       Net_mang_Form.disp_Label.Text = "Uploading File ..."
       Net_mang_Form.Prg_bar.Visible = True
       Net_mang_Form.Prg_bar.Value = 0
       'Net_mang_Form.prg_Timer.Interval = 30
       Dim t As New System.Timers.Timer
       'Dim t As New System.Windows.Forms.Timer
       AddHandler t.Elapsed, AddressOf THandler
       t.Interval = 50
       Me.uplod_btn.Enabled = False


       Dim chk As Integer = file_send(dev_id, dev_type, Net_mang_Form.snd_file_path, ip_addr & "#1206", contrl_id)

       '=================== Upload Process is finished =====================
       Net_mang_Form.disp_Label.Text = "Done"
       Net_mang_Form.Prg_bar.Visible = False
       Me.uplod_btn.Enabled = True

       If (chk = 1) Then

           MsgBox("Upload successful")
           MsgBox("Upload Fail.Check file_transfer_log.txt file")
       End If

   End Sub

Use backgroundworker component
Search for tutorial on Net
Share this answer
hello, you can put Timer1 in form1 and try .
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900