When I select a checkbox, the value gets added in the textbox and gets incremented when I check another. Problem is, when I uncheck them, it should subtract the values too. Total_sum in my textbox. Please help me.
Dim sum As Integer
Public Sub ChangeValue(add As Boolean, value As Decimal)
sum += If(add, value, -value)
Total_sum.Text = sum.ToString
End Sub
Private Sub chk_1_CheckedChanged(sender As Object, e As EventArgs) Handles chk_1.CheckedChanged
If chk_1.Checked = True Then
ChangeValue(DirectCast(sender, CheckBox).Checked = True, 25I)
End If
End Sub
Private Sub chk_2_CheckedChanged(sender As Object, e As EventArgs) Handles chk_2.CheckedChanged
If chk_2.Checked = True Then
ChangeValue(DirectCast(sender, CheckBox).Checked, 25I)
End If
End Sub
Private Sub chk_3_1_CheckedChanged(sender As Object, e As EventArgs) Handles chk_3_1.CheckedChanged
If chk_3_1.Checked = True Then
chk_3_2.Checked = False
ChangeValue(DirectCast(sender, CheckBox).Checked, 15I)
End If
End Sub
Private Sub chk_3_2_CheckedChanged(sender As Object, e As EventArgs) Handles chk_3_2.CheckedChanged
If chk_3_2.Checked = True Then
chk_3_1.Checked = False
ChangeValue(DirectCast(sender, CheckBox).Checked, 30I)
End If
End Sub
Private Sub chk_4_CheckedChanged(sender As Object, e As EventArgs) Handles chk_4.CheckedChanged
If chk_4.Checked = True Then
ChangeValue(DirectCast(sender, CheckBox).Checked, 20D)
End If
End Sub
Private Sub chk_5_1_CheckedChanged(sender As Object, e As EventArgs) Handles chk_5_1.CheckedChanged
If chk_5_1.Checked = True Then
chk_5_2.Checked = False
chk_5_3.Checked = False
ChangeValue(DirectCast(sender, CheckBox).Checked, 0D)
End If
End Sub
Private Sub chk_5_2_CheckedChanged(sender As Object, e As EventArgs) Handles chk_5_2.CheckedChanged
If chk_5_2.Checked = True Then
chk_5_1.Checked = False
chk_5_3.Checked = False
ChangeValue(DirectCast(sender, CheckBox).Checked, 15D)
End If
End Sub
You do not need the DirectCast. You know what the sender is. Just passing the Boolean chk_1.Checked to ChangeValue will either increment or decrement the sum.
Private sum As Integer
Public Sub ChangeValue(add As Boolean, value As Integer)
sum += If(add, value, -value)
Total_sum.Text = sum.ToString
End Sub
Private Sub chk_1_CheckedChanged(sender As Object, e As EventArgs) Handles chk_1.CheckedChanged
ChangeValue(chk_1.Checked, 25)
End Sub
Related
Good day!
so delete all the ticked entries from CheckedListBox
For Each item In CheckedListBox1.CheckedItems.OfType(Of String)().ToList()
CheckedListBox1.Items.Remove(item)
Next item
Tell me how to delete the selected entry in the CheckedListBox?
in the picture the record with the name 3 is highlighted. Is it possible and how to delete it without putting a check?
Here is a simple example for
Removing all checked items
Removing the current item disregarding the checked state.
Form code
Imports System.Globalization
Public Class Form1
Private Sub RemoveCheckedButton_Click(sender As Object, e As EventArgs) Handles RemoveCheckedButton.Click
If MonthCheckedListBox.CheckedItems.Count > 0 Then
MonthCheckedListBox.CheckedItems.Cast(Of String)().ToList().
ForEach(Sub(item) MonthCheckedListBox.Items.Remove(item))
SetActive()
End If
End Sub
Private Sub RemoveCurrentButton_Click(sender As Object, e As EventArgs) Handles RemoveCurrentButton.Click
If MonthCheckedListBox.Items.Count > 0 Then
MonthCheckedListBox.Items.RemoveAt(MonthCheckedListBox.SelectedIndex)
SetActive()
End If
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
MonthCheckedListBox.Items.AddRange(
Enumerable.Range(1, 12).
Select(Function(index)
Return DateTimeFormatInfo.CurrentInfo.GetMonthName(index)
End Function).ToArray())
SetActive()
End Sub
Private Sub SetActive()
ActiveControl = MonthCheckedListBox
If MonthCheckedListBox.Items.Count > 0 Then
MonthCheckedListBox.SelectedIndex = 0
End If
End Sub
End Class
Private Sub CheckedListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckedListBox1.SelectedIndexChanged
If isDeleted = False Then
isDeleted = True
CheckedListBox1.Items.RemoveAt(CheckedListBox1.SelectedIndex)
Else
isDeleted = False
End If
End Sub
Dim isDeleted As Boolean = False
Private Sub CheckedListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckedListBox1.SelectedIndexChanged
If isDeleted = False Then
isDeleted = True
CheckedListBox1.Items.RemoveAt(CheckedListBox1.SelectedIndex)
Else
isDeleted = False
End If
End Sub
Private Sub CheckedListBox1_Click(sender As Object, e As EventArgs) Handles CheckedListBox1.Click
Dim i As String = ""
i = CheckedListBox1.SelectedItem
If i = Nothing Then
Exit Sub
Else
CheckedListBox1.Items.Remove(i)
End If
End Sub
For index As Integer = CheckedListBox1.Items.Count - 1 To 0 Step -1
If CheckedListBox1.GetItemChecked(index) Then
CheckedListBox1.Items.RemoveAt(index)
End If
Next
I managed to make my app capture any key to use it as a hotkey, but when I press the key the hotkey function is activated. This is what I have so far:
Private Sub tmrFunc_Tick(sender As Object, e As EventArgs) Handles tmrFunc.Tick
'Function
End Sub
Private Sub tmrKey_Tick(sender As Object, e As EventArgs) Handles tmrKey.Tick
'Uses the hotkey to start and stop tmrF
End Sub
Private Sub lblCapKey_Click(sender As Object, e As EventArgs) Handles lblCapKey.Click
tmrKey.Enabled = False
txtbStartFunc.Enabled = True
txtbStartFunc.Text = "Press any key"
txtbStartFunc.Focus()
End Sub
Private Sub txtbStartFunc_KeyDown(sender As Object, e As KeyEventArgs) Handles txtbStartFunc.KeyDown
If e.KeyCode = Keys.F10 Then
txtbStartFunc.Text = "F10"
End If
tmrKey.Enabled = True
txtbStartFunc.Enabled = False
End Sub
The current code perfectly captures the key and uses it as a hotkey, the problem is that the hotkey is activated on this first key pressed and that causes it to be activated unexpectedly at the wrong time.
My current goal is that the function is not activated with the first keystroke, but is activated with the following keystrokes.
I am expecting something like this:
Private Sub txtbStartFunc_KeyDown(sender As Object, e As KeyEventArgs) Handles txtbStartFunc.KeyDown
If e.KeyCode = Keys.F10 Then
txtbStartFunc.Text = "F10"
End If
tmrKey.Enabled = True
'=========================
tmrFunc.Enabled = False
'=========================
txtbStartFunc.Enabled = False
End Sub
Here's a solution that finally worked for me. It allows you to set the hotkeys between F1 and F10, but won't let you select the same key for both of them.
This is pretty different than what you had, so take your time studying it and ask as many questions as need be:
Public Class Form1
Private Const KeyDownBit As Integer = &H8000
Private Enum HotKeyType
StartClicker
StopClicker
End Enum
Private _StartHotkey As Keys
Private _StopHotKey As Keys
Private SelectingHotKey As HotKeyType
Private HotKeySelected As Boolean = False
Private _SettingHotKey As Boolean = False
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKeys As Integer) As Short
Private Property StartHotKey As Keys
Get
Return _StartHotkey
End Get
Set(value As Keys)
If value <> StopHotKey Then
_StartHotkey = value
TextBox1.Text = StartHotKey.ToString
End If
End Set
End Property
Private Property StopHotKey As Keys
Get
Return _StopHotKey
End Get
Set(value As Keys)
If value <> StartHotKey Then
_StopHotKey = value
TextBox2.Text = StopHotKey.ToString
End If
End Set
End Property
Private Property SettingHotKey As Boolean
Get
Return _SettingHotKey
End Get
Set(value As Boolean)
If value Then
HotKeySelected = False
Timer2.Stop()
Else
Timer2.Start()
End If
_SettingHotKey = value
End Set
End Property
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.KeyPreview = True
Timer1.Enabled = False
Timer2.Enabled = False
Timer1.Interval = 50
Timer2.Interval = 50
TextBox1.ReadOnly = True ' they just stay this way all the time
TextBox2.ReadOnly = True ' they just stay this way all the time
StartHotKey = Keys.F1
StopHotKey = Keys.F2
Timer2.Start()
End Sub
Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
Dim startKeyDown, stopKeyDown As Boolean
GetAsyncKeyState(StartHotKey) ' disregard first call to "flush it"
startKeyDown = (GetAsyncKeyState(StartHotKey) And KeyDownBit) = KeyDownBit ' see if it's down
GetAsyncKeyState(StopHotKey) ' disregard first call to "flush it"
stopKeyDown = (GetAsyncKeyState(StopHotKey) And KeyDownBit) = KeyDownBit ' see if it's down
TextBox1.BackColor = If(startKeyDown, Color.Green, Control.DefaultBackColor)
TextBox2.BackColor = If(stopKeyDown, Color.Green, Control.DefaultBackColor)
If startKeyDown Then
Timer1.Start()
End If
If stopKeyDown Then ' if you hold both down, then it'll stop
Timer1.Stop()
Label1.BackColor = Control.DefaultBackColor
End If
End Sub
Private Sub BothButtons_Click(sender As Object, e As EventArgs) Handles Button1.Click, Button2.Click
SelectingHotKey = If(sender Is Button1, HotKeyType.StartClicker, HotKeyType.StopClicker)
SettingHotKey = True ' automatically turns off Timer2
Dim tb As TextBox = If(sender Is Button1, TextBox1, TextBox2)
tb.Text = "Press F1 to F10"
End Sub
Protected Overrides Function ProcessCmdKey(ByRef msg As Message, keyData As Keys) As Boolean
Select Case keyData
Case Keys.F1 To Keys.F10
If SettingHotKey Then
If SelectingHotKey = HotKeyType.StartClicker Then
If keyData <> StopHotKey Then
StartHotKey = keyData
HotKeySelected = True
Return True
End If
Else
If keyData <> StartHotKey Then
StopHotKey = keyData
HotKeySelected = True
Return True
End If
End If
End If
End Select
Return MyBase.ProcessCmdKey(msg, keyData)
End Function
Private Sub Form1_KeyUp(sender As Object, e As KeyEventArgs) Handles Me.KeyUp
If SettingHotKey AndAlso HotKeySelected Then
SettingHotKey = False ' restarts Timer2 once selected key has been released
End If
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Label1.BackColor = Color.Green
Label1.Text = DateTime.Now.ToString("HH:mm:ss.ffff") ' just to show it's "clicking"
End Sub
End Class
Okay, here's a little example of my program, which shows my problem.
This is the interface:
enter image description here
When I press F1, the counter starts to add 1 to itself, when I press F2, the counter stops. The Select button changes F1 to F9 or F2 to F10, but when I change the key the function is triggered, that is, if the counter is stopped, and the key is at F1, when I click Select to change from F1 to F9, the counter is activated.
Here is an example of the code, so you can see the problem first hand:
Public Class Form1
Declare Function GetAsyncKeyState Lib "user32" (ByVal vKeys As Integer) As Short
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Label1.Text += 1
End Sub
Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
Dim a, b As Boolean
If TextBox1.Text = "F1" Then
a = GetAsyncKeyState(Keys.F1)
ElseIf TextBox1.Text = "F9" Then
a = GetAsyncKeyState(Keys.F9)
End If
If TextBox2.Text = "F2" Then
b = GetAsyncKeyState(Keys.F2)
ElseIf TextBox2.Text = "F10" Then
b = GetAsyncKeyState(Keys.F10)
End If
If a = True Then
Timer1.Start()
ElseIf b = True Then
Timer1.Stop()
End If
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Timer2.Enabled = False
TextBox1.ReadOnly = False
TextBox1.Text = "Press any key"
TextBox1.Focus()
End Sub
Private Sub TextBox1_KeyDown(sender As Object, e As KeyEventArgs) Handles TextBox1.KeyDown
e.SuppressKeyPress = True
If TextBox1.ReadOnly = False Then
If e.KeyCode = Keys.F9 Then
TextBox1.Text = "F9"
Else
TextBox1.Text = "F1"
End If
End If
Timer2.Enabled = True
TextBox1.ReadOnly = True
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Timer2.Enabled = False
TextBox2.ReadOnly = False
TextBox2.Text = "Press any key"
TextBox2.Focus()
End Sub
Private Sub TextBox2_KeyDown(sender As Object, e As KeyEventArgs) Handles TextBox2.KeyDown
e.SuppressKeyPress = True
If TextBox2.ReadOnly = False Then
If e.KeyCode = Keys.F10 Then
TextBox2.Text = "F10"
Else
TextBox2.Text = "F2"
End If
End If
Timer2.Enabled = True
TextBox2.ReadOnly = True
End Sub
End Class
#Idle_Mind
Private Sub frmitem_Load(sender As Object, e As EventArgs) Handles MyBase.Load
pnldeposit.Visible = False
pnlwithdraw.Visible = False
End Sub
Private Sub cmdideposit_Click(sender As Object, e As EventArgs) Handles cmdideposit.Click
pnldeposit.Visible = True
pnlwithdraw.Visible = False
End Sub
Private Sub cmdiwithdraw_Click(sender As Object, e As EventArgs) Handles cmdiwithdraw.Click
pnlwithdraw.Visible = True
pnldeposit.Visible = False
End Sub
//i am having problem with this form. i want to show the first panel which is successful, but the problem is showing the second panel. it is not working, im using buttons btw. help me. Thank you in advance :D
Here is a quick example using BringToFront. With both panels having the same Location and being the same Size.
Public Class Form1
Private switchPanels As Boolean
Private Sub btn_Click(sender As Object, e As EventArgs) Handles btn.Click
switchPanels = Not switchPanels
If switchPanels Then
Panel1.BringToFront()
Else
Panel2.BringToFront()
End If
End Sub
End Class
Private Sub cmdideposit_Click(sender As Object, e As EventArgs) Handles cmdideposit.Click
pnldeposit.Visible = True
pnlwithdraw.Visible = False
pnlreport.Visible = False
End Sub
Private Sub cmddcancel_Click(sender As Object, e As EventArgs)
pnldeposit.Hide()
End Sub
Private Sub cmdiwithdraw_Click(sender As Object, e As EventArgs) Handles cmdiwithdraw.Click
pnlwithdraw.Visible = True
pnlreport.Visible = False
End Sub
Private Sub cmdwclear_Click(sender As Object, e As EventArgs) Handles cmdwclear.Click
pnlwithdraw.Visible = False
End Sub
Private Sub cmdireport_Click(sender As Object, e As EventArgs) Handles cmdireport.Click
pnlreport.Visible = True
End Sub
//thank you for sharing your idea! i found how it works. thanks! :D
I have set Datagridview .ReadOnly property to True, and then added a button column. Button column is meant for edit button when clicked, but I wish to edin only currently selected row. This is what I tried:
EDIT:
Public Class Form2
Private Sub Form2_Resize(sender As Object, e As EventArgs) Handles Me.Resize
Me.DataGridView1.Height = 0.8 * Me.Height
End Sub
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'Users._USERS' table. You can move, or remove it, as needed.
Me.USERSTableAdapter.Fill(Me.Users._USERS)
Me.DataGridView1.DefaultCellStyle.Font = New Font("Arial", 7)
End Sub
Protected Overrides Sub OnLoad(e As EventArgs)
MyBase.OnLoad(e)
For i As Integer = 0 To DataGridView1.Rows.Count - 1
DataGridView1.Rows(i).ReadOnly = True
Next
End Sub
Private Sub DataGridView1_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
Dim yourColumnIndex As Int32 = 3
If e.ColumnIndex = yourColumnIndex Then
If MsgBox("Do you wish to edit records?", vbQuestion + vbYesNo, "Edit records") = vbYes Then
DataGridView1.Rows(e.RowIndex).ReadOnly = False
End If
End If
End Sub
Private Sub DataGridView1_RowLeave(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.RowLeave
DataGridView1.Rows(e.RowIndex).ReadOnly = True
End Sub
End Class
You can't set the grid's ReadOnly property to true. After the rows are added to the grid, you would have to loop through your rows and set the ReadOnly property for each row:
Protected Overrides Sub OnLoad(e As EventArgs)
MyBase.OnLoad(e)
For i As Integer = 0 To DataGridView1.Rows.Count - 1
DataGridView1.Rows(i).ReadOnly = True
Next
End Sub
Note: you can't set these properties in the form's constructor, a quirk of the DataGridView control.
Then use the RowIndex property provided by the e parameter:
Private Sub DataGridView1_CellContentClick(sender As Object,
e As DataGridViewCellEventArgs)
Handles DataGridView1.CellContentClick
If e.ColumnIndex = 3 Then
DataGridView1.Rows(e.RowIndex).ReadOnly = False
End If
End Sub
Set it back to true when leaving the row:
Private Sub DataGridView1_RowLeave(sender As Object,
e As DataGridViewCellEventArgs)
Handles DataGridView1.RowLeave
DataGridView1.Rows(e.RowIndex).ReadOnly = True
End Sub
This is working, I just changed your suggestion a little bit (DatagridView Readonly property must be set to False):
Protected Overrides Sub OnLoad(e As EventArgs)
MyBase.OnLoad(e)
For Each band As DataGridViewBand In DataGridView1.Columns
band.ReadOnly = True
Next
End Sub
Private Sub DataGridView1_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
Dim yourColumnIndex As Int32 = 3
If e.ColumnIndex = yourColumnIndex Then
If MsgBox("Do you wish to edit record?", vbQuestion + vbYesNo, "Edit record") = vbYes Then
For Each band As DataGridViewBand In DataGridView1.Columns
band.ReadOnly = False
Next
End If
End If
End Sub
Private Sub DataGridView1_RowLeave(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.RowLeave
For Each band As DataGridViewBand In DataGridView1.Columns
band.ReadOnly = True
Next
End Sub
Thanks for all your help Lars!
I want to create a button that could stop my background worker and end all the process it is working on.
Here is my sample backgroundworker code:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Try
If BackgroundWorker1.IsBusy <> True Then
BackgroundWorker1.RunWorkerAsync()
End If
Catch ex As Exception
End Try
End Sub
Private Sub BackgroundWorker1_DoWork(sender As System.Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
Dim counter As Integer = 1
Do
'updated code with stop function----------------
BackgroundWorker1.WorkerSupportsCancellation = True
If BackgroundWorker1.CancellationPending Then
e.Cancel = True
ProgressBar1.Value = 0
Exit Do
End If
'updated code with stop function----------------
ListBox1.Items.Add(counter)
ProgressBar1.Value = ((counter - 1) / limit) * 100
counter = counter + 1
Loop While(counter <= 999999999999999999)
End Sub
Private Sub BackgroundWorker1_ProgressChanged(sender As System.Object, e As System.ComponentModel.ProgressChangedEventArgs) Handles BackgroundWorker1.ProgressChanged
Try
Catch ex As Exception
End Try
End Sub
Private Sub BackgroundWorker1_Completed(sender As System.Object, e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted
Try
Catch ex As Exception
End Try
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = False
End Sub
'updated code with stop function----------------
Private Sub StopButton_Click(sender As Object, e As EventArgs) Handles StopButton.Click
If BackgroundWorker1.IsBusy Then
If BackgroundWorker1.WorkerSupportsCancellation Then
BackgroundWorker1.CancelAsync()
End If
End If
End Sub
'updated code with stop function----------------
I want to reset the loop and return the Progress Bar to 0% when i stop the backgroundworker.
Is this possible?
The code above has been updated and it is now working fine.
I have added this code inside my do loop:
BackgroundWorker1.WorkerSupportsCancellation = True
If BackgroundWorker1.CancellationPending Then
e.Cancel = True
ProgressBar1.Value = 0
Exit Do
End If
I created a button that stops the worker:
Private Sub StopButton_Click(sender As Object, e As EventArgs) Handles StopButton.Click
If BackgroundWorker1.IsBusy Then
If BackgroundWorker1.WorkerSupportsCancellation Then
BackgroundWorker1.CancelAsync()
End If
End If
End Sub
The Backgroundworker class has the method CancelAsync() which you need to call to cancel the execution of the bgw.
You need to set the Backgroundworker.WorkerSupportsCancellation property to true and inside the while loop you need to check the CancellationPending property wether the value is true which indicates a call to the CancelAsync() method.
If CancellationPending evaluates to true, you would ( which you should have done already ) call one of the overloaded ReportProgress() (Docu) methods to set your ProgressBar value to the desired value.
EDIT: You should set the Cancel property of the DoWorkEventArgs to true so you can check the Cancelled property of the RunWorkerCompletedEventArgs inside the RunworkerCompletedevent.
You also shouldn not access any controls which lives in the UI thread. You better use the ProgressChanged(Docu) event.
See: BackgroundWorker Docu
Public Class Form1
Private iVal As Integer = 0
Private Sub bgw_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles bgw.DoWork
For iVal = iVal To 100 Step 1
bgw.ReportProgress(iVal)
Threading.Thread.Sleep(99)
If (bgw.CancellationPending = True) Then
e.Cancel = True
Exit For
End If
Next
End Sub
Private Sub bgw_ProgressChanged(ByVal sender As Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs) Handles bgw.ProgressChanged
pbar.Value = e.ProgressPercentage
lblProgrss.Text = e.ProgressPercentage.ToString() & "%"
End Sub
Private Sub bgw_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles bgw.RunWorkerCompleted
If (e.Cancelled = True) Then
pic.Visible = False
pbar.Value = iVal
lblProgrss.Text = iVal & "%"
btnstart.Text = "Start"
btnstart.BackColor = Color.Green
Else
pic.Visible = False
btnstart.Text = "Start"
btnstart.BackColor = Color.Green
iVal = 0
End If
End Sub
Private Sub btnstart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnstart.Click
If (btnstart.Text = "Start") Then
btnstart.Text = "Stop"
btnstart.BackColor = Color.Red
pic.Visible = True
bgw.RunWorkerAsync()
Else
If (bgw.IsBusy = True) Then
btnstart.Text = "Start"
btnstart.BackColor = Color.Green
bgw.CancelAsync()
End If
End If
End Sub
End Class