How to Create Your First Program in Visual Studio
Set up Visual Studio., Fire up Visual Studio from your start menu and create a new Visual Basic Project., On the right-hand side, go to the properties screen and change the following settings: FormBorderStyle : None StartPosition : CenterScreen...
Step-by-Step Guide
-
Step 1: Set up Visual Studio.
Before we get started, please read Install-and-Setup-Visual-Studio-Express-2013 to get Visual Studio installed for free, since you will need it for this project. , Please note, your Visual Studio version may vary.
Name your project SecondaryDesktop and click create.,, Select All Windows Forms, scroll down until you see Listview.
Do not confuse it with the Listbox.
Click on the Listview control and drag it onto your form., This will cause the control to fill the entire window it was placed in.
Now, prepare to add some code., You should see something similar to the image above.
From the combobox that says Listview1 choose (Form1 Events).
On the one on the right, choose Load.
Here we will enter the code that needs to be executed when our program is launched., Under the Form1_load section, enter the following code:
If Not My.Computer.FileSystem.DirectoryExists("desktop2") Then My.Computer.FileSystem.CreateDirectory("desktop2") End If This part (If Not My.Computer.FileSystem.DirectoryExists("desktop2") Then) checks if a folder with the name "desktop2" exists in the directory where our application is.
Else, it creates that folder using (My.Computer.FileSystem.CreateDirectory("desktop2")). , Now that you have somewhere to store your files, you need a way of loading them into our application.
Just under the "End Sub" part of Form1_Load, enter the following:
Sub LoadData() Press ↵ Enter.
The editor will automatically add the "End Sub" part. , For Each fl in My.Computer.FileSystem.GetFiles("desktop2") This gets all the files in our desktop ListView1.Items.Add(My.Computer.FileSystem.GetFileInfo(fl).Name) This adds the file into our desktop by getting it's name from the system. ,, Go to the following folder :
Your Documents > Visual Studio 2013 Express > Projects > SecondaryDesktop > Bin > Debug and create a folder named desktop2.
Next, enter your new folder and create a new folder inside., If all went well, you should see something like the screen above. -
Step 2: Fire up Visual Studio from your start menu and create a new Visual Basic Project.
-
Step 3: On the right-hand side
-
Step 4: go to the properties screen and change the following settings: FormBorderStyle : None StartPosition : CenterScreen Text : Desktop2
-
Step 5: Go to the Toolbox on the left-hand side.
-
Step 6: Click the little black arrow at the top of the newly added Listview and choose Dock in parent container.
-
Step 7: Double click on the window in front of you and it will switch over to the code editor.
-
Step 8: Enter the first part of the code.
-
Step 9: Add the loading code.
-
Step 10: Follow it up with the following code: For each dr in My.Computer.FileSystem.GetDirectories("desktop2") ListView1.Items.Add(My.Computer.FileSystem.GetDirectoryInfo(dr).Name) Next For Each fl in My.Computer.FileSystem.GetFiles("desktop2") ListView1.Items.Add(My.Computer.FileSystem.GetFileInfo(fl).Name) Next This code serves the following purposes: My.Computer.FileSystem.GetDirectories("desktop2") This gets all the folders in our desktop ListView1.Items.Add(My.Computer.FileSystem.GetDirectoryInfo(dr).Name) This adds the folder into our desktop by getting it's name from the system.
-
Step 11: Go back to the Form1_Load section and add the following line: LoadData() This calls the function we just created to load all the files and folders in our desktop.
-
Step 12: Test the current software.
-
Step 13: Click the Start button at the top of the screen.
Detailed Guide
Before we get started, please read Install-and-Setup-Visual-Studio-Express-2013 to get Visual Studio installed for free, since you will need it for this project. , Please note, your Visual Studio version may vary.
Name your project SecondaryDesktop and click create.,, Select All Windows Forms, scroll down until you see Listview.
Do not confuse it with the Listbox.
Click on the Listview control and drag it onto your form., This will cause the control to fill the entire window it was placed in.
Now, prepare to add some code., You should see something similar to the image above.
From the combobox that says Listview1 choose (Form1 Events).
On the one on the right, choose Load.
Here we will enter the code that needs to be executed when our program is launched., Under the Form1_load section, enter the following code:
If Not My.Computer.FileSystem.DirectoryExists("desktop2") Then My.Computer.FileSystem.CreateDirectory("desktop2") End If This part (If Not My.Computer.FileSystem.DirectoryExists("desktop2") Then) checks if a folder with the name "desktop2" exists in the directory where our application is.
Else, it creates that folder using (My.Computer.FileSystem.CreateDirectory("desktop2")). , Now that you have somewhere to store your files, you need a way of loading them into our application.
Just under the "End Sub" part of Form1_Load, enter the following:
Sub LoadData() Press ↵ Enter.
The editor will automatically add the "End Sub" part. , For Each fl in My.Computer.FileSystem.GetFiles("desktop2") This gets all the files in our desktop ListView1.Items.Add(My.Computer.FileSystem.GetFileInfo(fl).Name) This adds the file into our desktop by getting it's name from the system. ,, Go to the following folder :
Your Documents > Visual Studio 2013 Express > Projects > SecondaryDesktop > Bin > Debug and create a folder named desktop2.
Next, enter your new folder and create a new folder inside., If all went well, you should see something like the screen above.
About the Author
Teresa Robinson
A seasoned expert in lifestyle and practical guides, Teresa Robinson combines 13 years of experience with a passion for teaching. Teresa's guides are known for their clarity and practical value.
Rate This Guide
How helpful was this guide? Click to rate: