Click here to Skip to main content
15,921,382 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

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


VB
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, "\")
           Else
               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
       'Net_mang_Form.prg_Timer.Start()
       Dim t As New System.Timers.Timer
       'Dim t As New System.Windows.Forms.Timer
       AddHandler t.Elapsed, AddressOf THandler
       t.Interval = 50
       t.Start()
       'Net_mang_Form.upload_event()
       Me.uplod_btn.Enabled = False
       Windows.Forms.Application.DoEvents()

       '====================================================================

       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"
      
       t.Stop()
       Net_mang_Form.Prg_bar.Visible = False
       Me.uplod_btn.Enabled = True
       '====================================================================

       If (chk = 1) Then

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


   End Sub
Posted

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