StillLearning
Member
- Joined
- Dec 21, 2012
- Messages
- 12
- Programming Experience
- Beginner
When a folder is selected the fun starts...
Whenever I add and double-click a button in Form1.vb[Design] it creates a Private Sub in Public Class Form1.
I want to create what I can only describe in layman's terms as a global variable for the path which was selected.
I've tried several approaches similar to:
I can't do things like this within a Private Sub
Should I change the Private Sub to a Public Class?
I tried that, but I got several errors so I did the magical Undo... Do I need to work through these errors or is there a better way to share the FolderBrowserDialog1.SelectedPath with other modules and classes?
-----------------------------------
I've just about got my toy program the way I want it so now I'm trying to make it better and learn. I've been using:
Dim sourceDirectory As String = Form1.FolderBrowserDialog1.SelectedPath
at the beginning of modules and classes
and I have also just put the text in a TextBox on Form1 and pulled it from there, but...
I know there's a better way, and I'd like to learn...
Thank you for taking the time to read this.
Whenever I add and double-click a button in Form1.vb[Design] it creates a Private Sub in Public Class Form1.
I want to create what I can only describe in layman's terms as a global variable for the path which was selected.
I've tried several approaches similar to:
VB.NET:
Public Sub ButtonDataTable_Click(sender As Object, e As EventArgs) Handles ButtonDataTable.Click
If (FolderBrowserDialog1.ShowDialog() = DialogResult.OK) Then
Const sourceDirectory As String
sourceDirectory = FolderBrowserDialog1.SelectedPath
ModPopulateGrid.Main()
etc.
End Sub
I can't do things like this within a Private Sub
Should I change the Private Sub to a Public Class?
I tried that, but I got several errors so I did the magical Undo... Do I need to work through these errors or is there a better way to share the FolderBrowserDialog1.SelectedPath with other modules and classes?
-----------------------------------
I've just about got my toy program the way I want it so now I'm trying to make it better and learn. I've been using:
Dim sourceDirectory As String = Form1.FolderBrowserDialog1.SelectedPath
at the beginning of modules and classes
and I have also just put the text in a TextBox on Form1 and pulled it from there, but...
I know there's a better way, and I'd like to learn...
Thank you for taking the time to read this.
Last edited: