WTF ... IS WTF!?
We are a collective of people who believe in freedom of speech, the rights of individuals, and free pancakes! We share our lives, struggles, frustrations, successes, joys, and prescribe to our own special brand of humor and insanity. If you are looking for a great place to hang out, make new friends, find new nemeses, and just be yourself, WTF.com is your new home.

VB 6.0 Find By String code help

necro

Postaholic
1,375
59
137
#1
I am coding a single directory media player, and i need a find by string code so i can, well, find a song by string in the file1.listindex. I would appriciate the code, but if you do supply the code, i would appriciate it even more if you would explain it. I don't know why, but i refuse to use a code unless i know what each part of it does. Really, all i need is the explanation. Thanks.
 

Broken

Member smoked too much weed!
3,891
0
0
#2
What don't you understand? Show your code and I will help.
 

necro

Postaholic
1,375
59
137
#3
Well, I don't get the part where it finds the string, lol. This is a count by string code, but i figured if i could get this down, it wouldn't be hard to make it a find by string, play by string and random by string.

if lcase(chat) like ".count *" then
Dim i as string
Dim lame as string
Dim cbs as string
cbs$ = mid(chat, 7)
lame = 0
for i = 0 to file1.listcount - 1
if instr(file1.list(i), cbs$) = true then
lame = lame + 1
next i
Chatsend
End If
End If


To be completley honest, this is the only part i dont get.

lame = 0
for i = 0 to file1.listcount - 1
if instr(file1.list(i), cbs$) = true then
lame = lame + 1
next i

Thanks :thumbsup:
 

Broken

Member smoked too much weed!
3,891
0
0
#4
if the statement is true then load next from the list. that's it.
 

BRiT

CRaZY
Founder
11,744
2,428
487
#5
I commented the code inline...

To be completley honest, this is the only part i dont get.

lame = 0 ' sets the variable to be the value of 0
for i = 0 to file1.listcount - 1 ' loops through to the number of lines in the file
if instr(file1.list(i), cbs$) = true then ' if the value of CBS is in line number i of the file then do the inner processing
lame = lame + 1 ' increment the count of the variable
next i ' go back to beginning of loop and work on the next line

Thanks :thumbsup:
This is very basic VB. I suggest you find a book on this and read. Learning. You should try it.
 

necro

Postaholic
1,375
59
137
#6
Cheers, thanks alot, both of you. :thumbsup: