DFBarracks - Forums




Delta Force Barracks Forums - Powered by XMB 1.9.11
Delta Force Barracks Forums
Not logged in [Login - Register]
Go To Bottom

Printable Version  
Author: Subject: Tutorial Level: Beginner : OpenFile/SaveFile dialogues.
bullet magnet
Captain
****


Avatar


Posts: 263
Registered: 6-26-2005
Member Is Offline

Mood: Modding

[*] posted on 6-29-2007 at 08:38 AM
Tutorial Level: Beginner : OpenFile/SaveFile dialogues.


In almost EVERY program out there, the user opens a file for editing, changing, or anything else, this is what we will be discussing today.

1.) Add two buttons to your form, and a textbox, in textbox, click on it, then click the little arrow, and mark multi-line.


2.) Now double-click button1, this is the OpenFileDialog. Type code:

Code:
[size=3]Dim OpenFileDialog1 As New OpenFileDialog[/size]


We have now set a variable, "OpenFileDialog1" As an openfiledialog, where a user can select a file.

3.) Now lets play with the properties of this (it will be addressed by variable name "OpenFileDialog1")

Code:
[size=3]OpenFileDialog1.FileName = ""[/size]


What this does, is set the filename to empty so that the user can select his own file.

Code:
[size=3]OpenFileDialog1.Title = "Select File"[/size]


This sets the title of the dialog.

Code:
[size=3]OpenFileDialog1.Filter = "Text files (*.txt)|*.txt"[/size]


This will make it so that only Text Files may be selected.

Code:
[size=3]OpenFileDialog1.ShowDialog[/size]


Shows the Dialog.

Now I initially planned to go into reading the text file, but not now.

********Other Option************
If you don't want to declare the dialog as a variable, you can simply add it to your form.

Add an OpenFileDialog to your form from your ToolBox, and use the same code, except for the

Dim OpenFileDialog1 As New OpenFileDialog

Leave that out.





View user's profile View All Posts By User

  Go To Top

Powered by XMB 1.9.11
XMB Forum Software © 2001-2012 The XMB Group
[Queries: 15] [PHP: 53.6% - SQL: 46.4%]












Copyright © 2002 - 2008 All Rights Reserved - DFBarracks.com
Site Design by A.Bullet - ScreamingDemon.com