Reading Command Parameters
Have you ever wanted to click a file and open it? If your program is associated with a specified file type, or you select file(s) and drag them onto the exe icon of your app then this code is for you. It reads the parameters when the form is loaded using by getting the "Command". This code can get each file dragged or clicked on. If you just use the command statement you will get something like this "c:\george.bmp c:\ben.bmp f:\mydoc.doc". This code seperates each file and uses another sub to open it.
Shrnutí AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
'Code created by Jonathan Jarvis - Jman 'Email: [email protected] 'as of now this will require a listbox with a name of "List1" Private Sub getfiletoopen(filename As String) List1.AddItem filename End Sub Private Sub Form_Load() 'create variables Dim howlong, n As Integer, c As String 'give variables values c = Command n = 1 For howlong = Len(Command) To 1 Step -1 ' start loop statement If Mid(c, n, 1) = " " Then 'check to see if It should seperate commands getfiletoopen Mid(c, 1, n - 1) 'pick out the command from line only Mid(c, 1, n - 1) is the command file c = Right(c, Len(c) - n) 'change command and get rid of last handled file n = 0 'reset letter to 0 End If n = n + 1 'increment to next letter Next howlong 'go on to next letter 'takes care of last command line or 1st one if only one file is to be opened If c <> "" Then ' checks to see if there is a 1st or last command getfiletoopen c ' you can change this to load your file or command. c is the command parameter of the last file End If End Sub