Hi,
I'm fairly new to programming and VB.NET and am still struggeling with the way things work every now and again. Most thing are easily found on the net, but some aren't.
Background:
I created a function that retrieves information on which checkboxes are checked. It returns an array which the information coupled to the checking of those checkboxes. Those checkboxes and the matching textboxes are dynamically created at runtime in that same function. I'm pausing the application to wait for a button to be pressed. I'm trying to find a way to use btnDone.Click event directly because the code always reloops my function once more recreating the controls.
Right now I'm setting a create a boolean switch when btnSubDone is clicked. What I would like is for something along the lines of:
Is it possible to use events like this? If not is there a cleaner way for pausing the application to wait for a button click (one that doesn't run the entire function again)? Any help would be appreciated.
Thanks in advance
I'm fairly new to programming and VB.NET and am still struggeling with the way things work every now and again. Most thing are easily found on the net, but some aren't.
Background:
I created a function that retrieves information on which checkboxes are checked. It returns an array which the information coupled to the checking of those checkboxes. Those checkboxes and the matching textboxes are dynamically created at runtime in that same function. I'm pausing the application to wait for a button to be pressed. I'm trying to find a way to use btnDone.Click event directly because the code always reloops my function once more recreating the controls.
VB.NET:
Public Function GetArray(ByVal strDLFolder As String) As Array
If blnDone = False Then
Me.Show()
...
'Create controls here
...
Dim intNumber As Integer
Dim CheckedArray() As String
'AddHandler btnSubDone.Click, AddressOf btnDoneClicked
intNumber = -1
Do Until (blnDone = True)
Application.DoEvents()
Loop
ReDim CheckedArray(intArray)
For i = 0 To intArray
If ckbSubAdd(i).Checked = True Then
intNumber = intNumber + 1
CheckedArray(intNumber) = strFullPath(i)
End If
Next
VideoMover.Visible = True
blnDone = False
Return CheckedArray
Me.Close()
End Function
Public Sub btnSubDone_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubDone.Click
blnDone = True
Me.Visible = False
End Sub
VB.NET:
Do Until (btnSubDone.Click = True) 'The code is obviously wrong, It's meant to display what goes on in my mind
Application.DoEvents()
Loop
Is it possible to use events like this? If not is there a cleaner way for pausing the application to wait for a button click (one that doesn't run the entire function again)? Any help would be appreciated.
Thanks in advance