class form2
Private Sub ManagementButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ManagementButton.Click
Dim cReys As New RSD
Dim aReys As Array
.....................
Me.ToolStripProgressBar1.Maximum = UBound(aReys, 2) + 1
Me.ToolStripProgressBar1.Value = Me.ToolStripProgressBar1.Value + Me.ToolStripProgressBar1.Step
If Me.ManagementListBox.SelectedIndex = 0 Then
Dim cComplete As New Complete
cComplete.aReys = aReys
cComplete.GetComplete()
...................
Me.ToolStripProgressBar1.Value = 0
End Sub
end class
Private Delegate Sub DelegateSetProgressBar(ByVal i As Integer, ByVal all As Integer)
Private Sub SetProgressBar(ByVal i As Integer, ByVal all As Integer)
' See if we're on the worker thread and thus
' need to invoke the main UI thread.
If Me.InvokeRequired Then
' Make arguments for the delegate.
Dim args As Object() = {i, all}
' Make the delegate.
Dim Delegate_Set_ProgressBar As DelegateSetProgressBar
Delegate_Set_ProgressBar = AddressOf SetProgressBar
' Invoke the delegate on the main UI thread.
Me.Invoke(Delegate_Set_ProgressBar, args)
' We're done.
Exit Sub
End If
'
Const p = 100
Dim rst As Integer
rst = (i * p) / all
ProgressBar1.Value = Math.Round(rst, 0)
'
Select Case ProgressBar1.Value
Case Is >= 100
ProgressBar1.Visible = False
Case Is = 1
ProgressBar1.Visible = True
ProgressBar1.Value = 0
End Select
End Sub
Sub ImportData(ByVal R1C1 As Boolean)
'
Dim oldCI As System.Globalization.CultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture
System.Threading.Thread.CurrentThread.CurrentCulture = New System.Globalization.CultureInfo("en-US")
'
Dim i As Integer
Dim nm As Integer = 0
Dim Inserted As Integer = 0
'
Dim PrimerName As String
Dim Sequence As String
Dim Gene As String
Dim Temperature As Double
Dim Size As Integer
Dim Concentration As Double
'
Dim fn As String = FileIO.FileSystem.GetName(OpenFileDialog1.FileName)
'
For i = NumericUpDownFirstRow.Value To NumericUpDownLastRow.Value
Try
If R1C1 = False Then
PrimerName = oDocument.Worksheets(CurSheet).Cells(i, PrimerNameIndex).Value
Sequence = oDocument.Worksheets(CurSheet).Cells(i, SequenceIndex).Value
Gene = oDocument.Worksheets(CurSheet).Cells(i, GeneIndex).Value
Temperature = oDocument.Worksheets(CurSheet).Cells(i, TemperatureIndex).Value
Size = oDocument.Worksheets(CurSheet).Cells(i, SizeIndex).Value
Concentration = oDocument.Worksheets(CurSheet).Cells(i, ConcentrationIndex).Value
Else
PrimerName = oDocument.Worksheets(CurSheet).Cells(i, PrimerNameIndex).Value
Sequence = oDocument.Worksheets(CurSheet).Cells(i, SequenceIndex).Value
Gene = oDocument.Worksheets(CurSheet).Cells(i, GeneIndex).Value
Temperature = oDocument.Worksheets(CurSheet).Cells(i, TemperatureIndex).Value
Size = oDocument.Worksheets(CurSheet).Cells(i, SizeIndex).Value
Concentration = oDocument.Worksheets(CurSheet).Cells(i, ConcentrationIndex).Value
End If
'
Inserted = FormPrimers.PrimersTableAdapter.Insert(Now(), PrimerName, Sequence, Gene, Convert.ToDecimal(Temperature), Convert.ToInt32(Size), Convert.ToDecimal(Concentration), CurrentUserID, fn, True)
'
nm += 1
Dim all As Integer
all = NumericUpDownLastRow.Value
[b] SetProgressBar(i, all)[/b]
Catch ex As Exception
' AddLog("Error of import. Discrepancy of types of data.", False)
AddStatus("Error of import. Discrepancy of types of data.", False)
MsgBox(ex.Message)
Exit Sub
End Try
Next
System.Threading.Thread.CurrentThread.CurrentCulture = oldCI
'
StopThread()
End Sub
Private Sub ThreadTask()
If RadioButtonNO.Checked = True Then
ImportData(False)
Else
ImportData(True)
End If
End Sub
Private Sub ButtonGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonGo.Click
ButtonOpenBook.Enabled = False
ButtonGo.Enabled = False
Me.Refresh()
'
...
CurrentUserID = MDIParentMain.MyUser.UserID
If CheckBoxCheckImpData.Checked = True Then
ThreadTaskCheckData()
If DataCorrect = False Then
'If CheckMSExcelData() = False Then
AddLog("Error data type. Please, verify data type in the cells, or correct options in 'Range descriptions'.", False)
MsgBox("Error data type. Please, verify data type in the cells, or correct options in 'Range descriptions'.")
Exit Sub
Else
AddLog("Data are correct.", True)
End If
End If
'
If trd Is Nothing Then
' The thread isn't running. Start it.
AddStatus("Starting import", True)
ButtonImpCancel.Visible = True
TimeStart = DateTime.Now
[b] trd = New Thread(AddressOf ThreadTask)[/b] trd.Priority = ThreadPriority.BelowNormal
trd.IsBackground = True
trd.Start()
AddStatus("Import started", True)
TabControl1.SelectedIndex = 2
Else
' The thread is running. Stop it.
trd.Abort()
trd = Nothing
End If
End Sub
Private Sub ButtonImpCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonImpCancel.Click
StopThread()
End Sub
Private Sub StopThread()
If trd Is Nothing Then
Else
' The thread is running. Stop it.
AddStatus("Stopping import", False)
TimeEnd = DateTime.Now
TimeDelta = (TimeStart.Minute - TimeEnd.Minute) * (-1)
AddStatus("Time of import is " + TimeDelta.ToString + " min.", True)
'
RestoreButtons()
'
trd.Abort()
trd = Nothing
End If
End Sub
Сейчас этот форум просматривают: Mail.ru [бот] и гости: 19