|
-
Mar 9th, 2003, 03:45 PM
#1
Thread Starter
Lively Member
Little Code Thing
Hello all, how are you? Ok I have a question concering if the code In my program is to much and can be shorter if its bad or what not?
VB Code:
Dim ArrItems As Variant
Dim I As Integer
ArrItems =
Array(""Mr.","The-","www.","Dr","Dr+","Dr.""pimp.","yahoo.","name.","login.","login-","login+","name+","my+","sos+","*****+","pimp+","freak+","lucky+","Mister+","Mrs+","cool+","bad+","****.","****+","Da-","name-","Mrs.","Cool-","Yahoo-","Miss-","Mister-","Master-","Boy-","Kid-","Guy-","Lady-","Woman-","Girl-","krack-","crack-","Goth-","Gothic-","Group-","Idol-","Erotic-","Era-","Main-","Satan-","Hero-","Evil-","Happy-","Fun-","Funny-","Doctor-","King-","Dog-","Dogg","420","187","Mr.+","The+","Dr.+","Da+","Mrs.+","Cool+","Yahoo+","Miss+","Mister+","Master+","Boy+","Kid+","Guy+","Lady+","Woman+","Girl+","Happy+","Fun+","Funny+","Doctor+","King+","Dog+","Dogg+","Pimp.+","420+","187+","yahoo_")
For I = 0 To UBound(ArrItems)
List1.AddItem ArrItems(I) & Text1.Text
Next I
So Im wondering if this code can be made shorter or more useful? Thanks in advance for some help and its very much appreciated. Have a good day
Have A Good Day 
-
Mar 9th, 2003, 04:01 PM
#2
Sleep mode
You mean this way :
VB Code:
Array(""Mr.","The-","www.","Dr","Dr+","Dr.""pimp.","yahoo.", _
"name.","login.","login-","login+","name+","my+","sos+" _
,"*****+",
"pimp+","freak+","lucky+","Mister+","Mrs+","cool+", _
"bad+","****.","****+","Da-","name-","Mrs.","Cool-", _
"Yahoo-","Miss-","Mister-","Master-","Boy-","Kid-","Guy-" _
,"Lady-","Woman-","Girl-","krack-","crack-","Goth-","Gothic-","Group-","Idol-","Erotic-","Era-","Main-","Satan-","Hero-", _
'etc .......
-
Mar 9th, 2003, 04:02 PM
#3
Frenzied Member
It looks pretty short, but usefull is up to you 
It would be more efficient (faster) to add the items into the list box 1 directly instead of writing them to an array and then looping through the array and adding them to the list box in the loop, unless you need them in an array for some other reason.
-
Mar 9th, 2003, 04:05 PM
#4
Sleep mode
either you store them in a file or in a database !
-
Mar 9th, 2003, 04:07 PM
#5
Thread Starter
Lively Member
No I dont but I thought it would be faster then:
VB Code:
List1.Additem Text1.Text & "*****"
List1.AddItem Text1.Text & "Mrs"
I thought that would be worse because its a lot more code and stuff? So I dont need an array so would you suggest it this way or another? Thanks in advance for some help man
Have A Good Day 
-
Mar 9th, 2003, 04:12 PM
#6
Fanatic Member
Originally posted by NoobieVb
No I dont but I thought it would be faster then:
VB Code:
List1.Additem Text1.Text & "*****"
List1.AddItem Text1.Text & "Mrs"
I thought that would be worse because its a lot more code and stuff? So I dont need an array so would you suggest it this way or another? Thanks in advance for some help man
Lesson 1. More code doesn't always equal slower
-
Mar 9th, 2003, 04:18 PM
#7
Thread Starter
Lively Member
Hehe yes I know so now im just curious which ones more effecinece and betetr to use all the long code List1.AddItem or the array? Thanks in advance for some help I really appreciate it
Have A Good Day 
-
Mar 9th, 2003, 04:34 PM
#8
Thread Starter
Lively Member
ANyone at all please? Id really appreciate it
Have A Good Day 
-
Mar 9th, 2003, 04:40 PM
#9
Fanatic Member
Originally posted by NoobieVb
ANyone at all please? Id really appreciate it
Lesson 2: All in good time
ok enough with the lessons
try making a quick program to measure the times between them.
Also if you not going to be continuly calling the code, you might aswell leave it because if it only gets called once, you only gonna save about 0.00000000001 seconds for one of the methods.
-
Mar 9th, 2003, 04:53 PM
#10
Frenzied Member
Originally posted by NoobieVb
No I dont but I thought it would be faster then:
VB Code:
List1.Additem Text1.Text & "*****"
List1.AddItem Text1.Text & "Mrs"
I thought that would be worse because its a lot more code and stuff? So I dont need an array so would you suggest it this way or another? Thanks in advance for some help man
The "more code" solution is faster. Your shorter version does the exact same thing, except it also creates an array, fills the array, and then accesses each item of the array.
The reason yours looks "faster" is because the AddItem step is performed in a loop, instead of written out one line at a time.
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
|