|
-
Jun 22nd, 2006, 08:37 AM
#1
Thread Starter
Addicted Member
-
Jun 22nd, 2006, 11:03 AM
#2
Re: [2005] how can i loop this text..
1) "If fileExists = True Then" takes more code, and more time to run, than "If fileExists Then"
2) Dim all your strings at the top. It's cleaner looking code, and Dim statements are executed unconditionally.
3) If you define your string as an array of string, you can build the file name based on the loop counter and your string is ArrayName(<loop counter>).
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.
Please Help Us To Save Ana
-
Jun 22nd, 2006, 12:04 PM
#3
Lively Member
Re: [2005] how can i loop this text..
If you are linking buttons to files, I would load them dynamically at runtime instead of having a set number of buttons already on the form. Then just set the Tag property of each dynamically loaded button to contain the contents of the files. Also, I'd use a For Each loop on IO.Directory.GetFiles to dynamically load the favorites.
Or actually, if you are making a browser favorites list, I would try to go with a single formatted document that contains all the favorites and then just load the single file. It'd probably be faster than opening and closing a lot of files on the hard drive, if you just open 1 file and loop through it line by line.
And a side note, if you want to post code, use the [vbcode] tags so your code is easy to read in the forums.
-
Jun 22nd, 2006, 12:48 PM
#4
Thread Starter
Addicted Member
-
Jun 22nd, 2006, 01:25 PM
#5
Lively Member
Re: [2005] how can i loop this text..
 Originally Posted by Gameunreal
Just do a really simple formatted file named something like "favorites.txt":
Code:
Website Title|http://www.website.com
Super Cool Site|http://www.supercool.com
Google|http://www.google.com
and to read it, use a StreamReader or TextReader to read the file in:
VB Code:
Dim Temp As String TempA() As String
Dim sr As New StreamReader("favorites.txt")
Do While sr.Peek <> -1
Temp = sr.ReadLine()
TempA = Temp.Split("|")
' here is where you would create the dynamic control
' whether it be a button or a menu item, then
YourDynamicItem.Text = TempA(0)
YourDynamicItem.Tag = TempA(1)
Loop
And just so you know, your zip file is missing a lot of image files in the resource folder. I had to create a bunch of fake ones to coerce the program into compiling.
-
Jun 22nd, 2006, 02:17 PM
#6
Hyperactive Member
Re: [2005] how can i loop this text..
Should have just debugged it, or downloaded mine: http://www.freewebs.com/tegadigital/. And I'm not saying mine is better but just saying if you wanted to try it out go ahead....I'm uploading a better version over the weekend.
"Imagination is more important than knowledge" - Albert Einstein, born on March 14th 1879.
Can't find it here on VBForums? Go to the CodeProject. MSDN is your friend . I have such a bad website, my friend decided it would be funny to change the template and he moderates the site for me: visit my site!
"Thinking of you, wherever you are
We pray for our sorrows to end, and hope that our hearts will blend.
Now I will step forward to realize this wish.
And who knows, starting a new journey may not be so hard…
Or maybe it has already begun.
There are many worlds, but they share the same sky
one sky, one destiny..."
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
|