Public Class DynamicRecordForm
    Public bEnableRecord As Boolean
    Public sRootFolder As String
    Private Sub DynamicRecordForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        bEnableRecord = False
        sRootFolder = ""

        cbEnableAudioRecord.Checked = bEnableRecord
        If bEnableRecord Then
            tbRootFolder.Enabled = True
            tbRootFolder.Text = sRootFolder
            btnBrowse.Enabled = True
        Else
            tbRootFolder.Enabled = False
            tbRootFolder.Text = sRootFolder
            btnBrowse.Enabled = False
        End If

    End Sub

    Private Sub cbEnableAudioRecord_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbEnableAudioRecord.CheckedChanged
        If cbEnableAudioRecord.Checked Then
            tbRootFolder.Enabled = True
            btnBrowse.Enabled = True
        Else
            tbRootFolder.Enabled = False
            btnBrowse.Enabled = False
        End If
    End Sub

    Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
        bEnableRecord = cbEnableAudioRecord.Checked
        If bEnableRecord Then
            sRootFolder = tbRootFolder.Text
        End If
        DialogResult = DialogResult.OK
        Close()
    End Sub

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        DialogResult = DialogResult.Cancel
        Close()
    End Sub

    Private Sub btnBrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBrowse.Click
        If folderBrowserDialog1.ShowDialog() = DialogResult.OK Then
            tbRootFolder.Text = folderBrowserDialog1.SelectedPath
        End If
    End Sub
End Class