|
-
Oct 4th, 2004, 10:02 AM
#1
Thread Starter
Lively Member
search a string
search a string
i creatied thsi code
VB Code:
Private Sub Command1_Click()
Dim ophalen As String
Dim tekst1 As String
Dim tekst2 As String
Dim splitter As String
Open "c:/program files/call of duty/main/config_mp.cfg" For Input As #1
ophalen = Input(LOF(1), #1)
Close #1
For i = 0 To 200
splitter = Split(ophalen, Chr(10))(i)
[COLOR=red]
if spitter. = "seta name" then
stop the i
tekst1 = Replace(splitter, "seta name", "")
tekst2 = Replace(tekst1, Chr(34), "")
Text2.Text = tekst2
Else
Next i
End If
[/COLOR]
End Sub
there are error's offcourse
the red part shows an if i want to detect the if or the first 9 character = "seta name"
if not go to next i and else stop the loop
i already know that there are more characters present in this part
hope someone can help me with that part
Last edited by davyquyo; Oct 4th, 2004 at 10:58 AM.
-
Oct 4th, 2004, 10:28 AM
#2
Frenzied Member
Use the InStr() function, it'll return 0 if the string wasn't found, and the position of the search string if found.
An example of its usage:
VB Code:
Dim sString As String
sString = "The life of the wife, was ended by the knife"
'InStr syntax: InStr(Starting point in string, String to search, String to search for)
If InStr(0, sString, "knife") > 0 Then
MsgBox "There's a knife in the string!"
End If
"Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
- Zack de la Rocha
Hear me roar.
-
Oct 4th, 2004, 10:32 AM
#3
Thread Starter
Lively Member
ok and how can i stop the loop
-
Oct 4th, 2004, 10:33 AM
#4
Frenzied Member
I believe 'Exit' does the trick... You could use a GoTo statement, though that is rather messy.
"Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
- Zack de la Rocha
Hear me roar.
-
Oct 4th, 2004, 10:36 AM
#5
Thread Starter
Lively Member
For i = 0 To 200
splitter = Split(ophalen, Chr(10))(i)
If InStr(0, splitter, "seta name") > 0 Then
exit i
MsgBox splitter
tekst1 = Replace(splitter, "seta name", "")
tekst2 = Replace(tekst1, Chr(34), "")
Text2.Text = tekst2
Else
Next i
ok when i test it say
next without loop
and exit is wrong to
-
Oct 4th, 2004, 10:44 AM
#6
Frenzied Member
Please remember to format your code... You have an open If statement:
VB Code:
For i = 0 To 200
splitter = Split(ophalen, Chr(10))(i)
If InStr(0, splitter, "seta name") > 0 Then
MsgBox splitter
tekst1 = Replace(splitter, "seta name", "")
tekst2 = Replace(tekst1, Chr(34), "")
Text2.Text = tekst2
Exit For
Else
'Do Nothing
End If
Next
Try this out, if it doesn't work, play with it - else do a forum search... You gotta be more active if you want problems solved, you need to take on affairs yourself...
"Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
- Zack de la Rocha
Hear me roar.
-
Oct 4th, 2004, 10:46 AM
#7
Thread Starter
Lively Member
If InStr(0, splitter, "seta name") > 0 Then
with this he says
invalid call or arument
-
Oct 4th, 2004, 10:48 AM
#8
Thread Starter
Lively Member
ok If InStr(1, splitter, "seta name", vbTextCompare) > 0 Then
this did the trick
it's alright
-
Oct 4th, 2004, 10:48 AM
#9
Frenzied Member
That's my bad, change '0' to '1' since a string doesn't have a 0 caracter... This, however, you should've been able to figure out yourself, just goes to show you didn't try any other options...
"Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
- Zack de la Rocha
Hear me roar.
-
Oct 4th, 2004, 10:51 AM
#10
Thread Starter
Lively Member
i search on google for the answer but i find always more complicated scripts
so i ask here to
i realy try but i don't know so much about vb i'm a flashscrpter but i need a program to run local for my website
that's why i'm using vb for
-
Oct 4th, 2004, 10:54 AM
#11
Frenzied Member
This board has a very advanced search function, right here:
http://www.vbforums.com/search.php?s=
Since the post archives are constantly growing, and are very big at the moment, you should be able to find the code blocks you need.
If your code is working as it should, please make this thread resolved - if you don't know how, look at the announcement in one of the forum sections.
"Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
- Zack de la Rocha
Hear me roar.
-
Oct 4th, 2004, 10:57 AM
#12
Thread Starter
Lively Member
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
|