VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



This code is to show you how one should go about making a simple listbox saving program.

by Matthew Acosta (Fr0st) (2 Submissions)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Thu 22nd June 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)

This code is to show you how one should go about making a simple listbox saving program.

API Declarations


'download a very usefull bas file
'at
'http://www.crosswinds.net/~thenewreign2/

Rate This code is to show you how one should go about making a simple listbox saving program.



'Step 1:
'Put a common dialog box on a form and name it 
'work
'Step2:
'Put a listbox on the form name it
'List1
'Step3:
'now up load the bas file.
'Step4:
'Place two command buttons on the form.
'name the first command button 
'add
'name the second one
'remove
'With all this in mind and all this done (must have bas) then lets start.
Form_Load()
'**NOTE** you will probably get an error when you first run the program.
'It should come in the load even of the listbox.
'Why is this? Well it happens because you have not created the file it 
'is searching for just yet.
'how will the file be created? Later on in this code you'll see it  comes under 
'the unload event.
'this tells vb to load example.ini from the desktop into the listbox
ListLoad List1, "C:\Windows\Desktop\example.ini"
End Sub

Private Sub Label1_DblClick()
'Shell opens the program and the list1.text tells it what to open.
Shell (List1.text)
End Sub

Private Sub Add_Click()
'The on error line tells the common dialog that it should go to the part 
'of don to catch the errors
On error goto don
'This tells it ok now with work...do these things 
'Remember work is our name for the common dialog box
With work
'makes the cancelerror true
.cancelerror = true
'tells our common dialog box to look for exe 's
.filter = "exe(*.exe)|*.exe"
'Filter Index, well it's suppose to go to 1
.filterindex =1
'End's the commands for the common dialog control
end with
'opens the common dialog box and says ok now tell me what to open
'**Note** Above we told the common dialog box to search for exe's
'If you want to add mroe you can just a 
',
'And start with another thing
'Still don't get it? here
'filter= "exes(*.exe)|*.exe), bas(*.bas)|*.bas" 
'Still don't get it...perhaps you might want to brush up on yer vb.
work.showopen
'Tells to list the path name from which the exe was selected and put it 
'in the listbox
list1.additem work.filename
'Like i said earlier catches the errors and sends them here
don:
End Sub

Private Sub Remove_Click()
'This removes the selected item from the listbox
list1.removeitem (list1.listindex)
End Sub

Private Sub Unload()
'This is necessary for making your program even better ;)
'filesave command tells your program to create this example.ini file 
'and stor it on the desktop...you may store it where ever you like
'I just put desktop so you can see where it went and don't get all freaked.
FileSave list1, "C:\Windows\Desktop\example.ini"
'This puts all that you have in the listbox into the ini file we have 
'created.
ListSave list1,"C:\Windows\Desktop\example.ini"
End Sub

Download this snippet    Add to My Saved Code

This code is to show you how one should go about making a simple listbox saving program. Comments

No comments have been posted about This code is to show you how one should go about making a simple listbox saving program.. Why not be the first to post a comment about This code is to show you how one should go about making a simple listbox saving program..

Post your comment

Subject:
Message:
0/1000 characters