|
-
Jan 11th, 2007, 05:00 PM
#1
Thread Starter
Hyperactive Member
-
Jan 11th, 2007, 05:03 PM
#2
PowerPoster
Re: list box help!
Rather than a database, why not save the list in a file?
And rather than a listbox, why not use a listVIEW? You could have a column for the name and another for the IP address
Well, everyone else has been doing it :-)
Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
Expect more to come in future
If I have helped you, RATE ME! :-)
I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!
And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.
-
Jan 11th, 2007, 05:04 PM
#3
Re: list box help!
I would store it in a flat text file. No need for a database with something like this.
-
Jan 11th, 2007, 05:25 PM
#4
Thread Starter
Hyperactive Member
Re: list box help!
pls could you explain how to do this as i have never used a listVIEW or written to a text file
-
Jan 11th, 2007, 05:48 PM
#5
Re: list box help!
 Originally Posted by chris1990
pls could you explain how to do this as i have never used a listVIEW or written to a text file
I'm writing an example for you.
-
Jan 11th, 2007, 05:57 PM
#6
PowerPoster
Re: list box help!
I'll let someone else explain listview, I've still not got my head around them...they're a lot more flexible than listboxes though :-)
Loading and saving to a text file is a simple matter, firstly you need to open the file
VB Code:
Open "filename" for Input as #1
Replace the Input with Output if you want to save rather than load (Input is load). Also, some people (me included) suggest not using a static value for the file number (in this case, 1)...I've kept it simple for you. When you're used to loading/saving ask for a better way and we'll give it :-)
Now you need to input/write something
Obviously "datastring" is the variable...this inputs a part of the textfile to the variable "datastring". Change Input to Print to write to the file.
This closes the file and ensures that it is saved properly (if you're saving) or available for use (if loading)
If you need to load/save multiple parts, you just enclose it in a loop of some sort (your choice, for/next, do/loop whatever). Most people put a "Do" before and a "Loop while not EOF(1)" after...EOF is End Of File and this basically loops until the file is at the end then closes...it's up to you to make sure each loaded/saved item is different each time it loops (put a variable number in there somewhere and increment it :-))
For instance, if you're saving address(1) to address(10) to "addresses.txt" you'd do:
VB Code:
fre = FreeFile 'Note I added this...this is the trick I told you about
Open "addresses.txt" for Output as #fre
For b = 1 to 10
Print #fre, address(b)
Next b
Close 1
Now loading it back
VB Code:
fre = FreeFile 'Note I added this...this is the trick I told you about
Open "addresses.txt" for Input as #fre
b=0
Do
b=b+1
Input #fre, address(b)
Loop while not EOF(fre)
Close fre
Edit: This has been bugging me for AGES...I *knew* I made the mistake of putting "Close 1" in the load back where it should be "Close fre"...corrected :-)
Last edited by smUX; Jan 12th, 2007 at 11:59 AM.
Well, everyone else has been doing it :-)
Loading a file into memory QUICKLY - Using SendKeys - HyperLabel - A highly customisable label replacement - Using resource files/DLLs with VB - Adding GZip to your projects
Expect more to come in future
If I have helped you, RATE ME! :-)
I love helping noobs with their VB problems (probably because, as an amateur programmer, I am only slightly better at VB than them :-)) but if you SERIOUSLY want to get help for free from a community such as VBForums, you have to first have a grounding (basic knowledge) in VB6, otherwise you're way too much work to help...You've got to give a little if you want to get help from us, in other words!
And we DON'T do your homework. If your tutor doesn't teach you enough to help you make the project without his or her help, FIND A BETTER TUTOR or try reading books on programming! We are happy to help with minor things regarding the project, but you have to understand the rest of it if you want our help to be useful.
-
Jan 11th, 2007, 07:27 PM
#7
Re: list box help!
Store it in a textfile with delimiters a new line or tab.
-
Jan 12th, 2007, 08:14 AM
#8
Re: list box help!
 Originally Posted by chris1990
Is there another way of doing this without using the database as it wont work.
This is exactly what I would do. Why won't it work?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|