This article has been dead for over three months
You
Public Class Form1
#Region "== VARIABLES =="
'set the variables
Private myCoolSetupLocation As String
Private myCoolRunProgramVar As Boolean
Private myCoolWebsiteVar As Boolean
#End Region
#Region "== APP STARTUP/FORM LOAD =="
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'hides the tab headers
Me.myCoolTabControl.Region = New Region(New RectangleF(Me.myCoolWelcomePage.Left, Me.myCoolWelcomePage.Top, Me.myCoolWelcomePage.Width, Me.myCoolWelcomePage.Height))
'pre-define a setup location
myCoolSetupLocation = System.Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) & "\myCoolAppName"
myCoolTextbox.Text = myCoolSetupLocation
End Sub
#End Region
#Region "== WELCOME TAB =="
'handles the 'next' button on the welcome tab
Private Sub myCoolNextButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles myCoolNextButton.Click
'// Next Tab.
With myCoolTabControl
.SelectedIndex += 1
End With
End Sub
#End Region
#Region "== LOCATION TAB =="
Private Sub myCoolBrowseButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles myCoolBrowseButton.Click
With FolderBrowserDialog1
.RootFolder = Environment.SpecialFolder.MyComputer 'define the folder that will be selected when folderbrowsedialog opens
.ShowNewFolderButton = True 'shows a 'new folder button
End With
If FolderBrowserDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then 'shows the dialog
myCoolSetupLocation = FolderBrowserDialog1.SelectedPath 'and, if the result was OK, assign the selected path to our variable
myCoolTextbox.Text = myCoolSetupLocation 'shows the selected path on the textbox control
End If
End Sub
'will check if the textbox is empty. if yes, disables the next button. DOES NOT VERIFY IF THE CONTENT ON THE TEXTBOX IS A VALID DIRECTORY!
Private Sub myCoolTextbox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles myCoolTextbox.TextChanged
If myCoolTextbox.Text = "" Then
myCoolNextButton2.Enabled = False
End If
End Sub
'handles the 'next' button on the location tab
Private Sub myCoolNextButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles myCoolNextButton2.Click
'checks if the variable has the same content of the textbox. If not, it will assign the textbox content to the variable
If myCoolTextbox.Text <> myCoolSetupLocation Then
myCoolSetupLocation = myCoolTextbox.Text
End If
'// Next Tab.
With myCoolTabControl
.SelectedIndex += 1
End With
End Sub
'handles the 'back' button on the location tab
Private Sub myCoolBackButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles myCoolBackButton2.Click
'// Previous Tab.
With myCoolTabControl
.SelectedIndex -= 1
End With
End Sub
#End Region
#Region "== PROGRESS TAB =="
'will not be used on the final code. will be replaced with the unpack data code, and registry operations. is here only for learning purposes. handles the next button
Private Sub myNotSoCoolNextButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles myNotSoCoolNextButton.Click
With myCoolTabControl
.SelectedIndex += 1
End With
End Sub
#End Region
#Region "== FINISH TAB =="
'checks if the run program checkbox is checked, and then sets the corresponding variable to true/false.
Private Sub myCoolRunCheckbox_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles myCoolRunCheckbox.CheckedChanged
If myCoolRunCheckbox.CheckState = CheckState.Checked Then
myCoolRunProgramVar = True
ElseIf myCoolRunCheckbox.CheckState = CheckState.Unchecked Then
myCoolRunProgramVar = False
End If
End Sub
'checks if the visit website checkbox is checked, and then sets the corresponding variable to true/false.
Private Sub myCoolSiteCheckbox_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles myCoolSiteCheckbox.CheckedChanged
If myCoolSiteCheckbox.CheckState = CheckState.Checked Then
myCoolWebsiteVar = True
ElseIf myCoolSiteCheckbox.CheckState = CheckState.Unchecked Then
myCoolWebsiteVar = False
End If
End Sub
'finish button handler
Private Sub myCoolFinishButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles myCoolFinishButton.Click
'check the values of the variables defined before
If myCoolRunProgramVar = True Then
'be sure to add a valid process, or it will throw a error
Process.Start("path to process")
End If
If myCoolWebsiteVar = True Then
Process.Start("http://www.daniweb.com")
End If
Me.Close()
End Sub
#End Region
End Class