|
-
Nov 3rd, 2000, 04:23 PM
#1
Thread Starter
Fanatic Member
How can u search a string if it contains a certain text I specify!
Visual Basic 6.0
Visual C++ 5
Delphi 5

-
Nov 3rd, 2000, 04:27 PM
#2
Monday Morning Lunatic
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Nov 3rd, 2000, 04:29 PM
#3
Hyperactive Member
Use Instr
Code:
InStr(1, Tosearchtext, "lookingfortext") ' 1 is the starting postion
][P
Visual Basic 6 SP4 on win98se
QUIT THE RAT RACE BECAUSE YOUR MESSING THE WORLD UP !!!!!
-
Nov 3rd, 2000, 04:30 PM
#4
Thread Starter
Fanatic Member
can u explain it's parameters like [start] and string1 and string2 and stuff like that, what do they mean
Visual Basic 6.0
Visual C++ 5
Delphi 5

-
Nov 3rd, 2000, 04:30 PM
#5
Thread Starter
Fanatic Member
Visual Basic 6.0
Visual C++ 5
Delphi 5

-
Nov 3rd, 2000, 04:35 PM
#6
Monday Morning Lunatic
string1 - string to look in
string2 - string to search for
start - character to begin searching from (1 = first char)
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Nov 3rd, 2000, 04:38 PM
#7
New Member
Use InStr function
InStr([start_pos],str_to_search,search_for [,compare_type])
Ex:
Dim x as Integer
Dim strToSrch as String
strToSrch = "This is so easy..."
x = InStr(strToSrch, "easy")
If string was found the value of the x will be stating position of the string (in this case x=12).
If string was not found then x=0
 File not found!
Abort, Retry, Get a Beer...
L8r
-
Nov 3rd, 2000, 04:38 PM
#8
Thread Starter
Fanatic Member
OK, what if I want it to return a word from a specific line!
Visual Basic 6.0
Visual C++ 5
Delphi 5

-
Nov 3rd, 2000, 04:49 PM
#9
Monday Morning Lunatic
You can't as such, since a logical line is terminated by a newline, not where it wraps on-screen. Try splitting the lines up, and searching individually.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Nov 3rd, 2000, 04:52 PM
#10
Thread Starter
Fanatic Member
This is what I mean!
I have lets say 4 lines:
hello there.
My Name is VIP3R.
I'm making a program!
This program is not working.
and i want my program to return VIP3R from the second line!
Visual Basic 6.0
Visual C++ 5
Delphi 5

-
Nov 3rd, 2000, 04:57 PM
#11
transcendental analytic
This might be something you need:
Code:
Function RetLineWord(ByVal str As String, linenum As Long, wordnum As Long) As String
Dim x&, pos&, pos2&
For x = 2 To linenum
pos = InStr(pos + 1, str, vbCrLf)
pos = pos + 1
Next x
For x = 2 To wordnum
pos = InStr(pos + 1, str, " ")
Next x
pos2 = InStr(pos + 1, str, " ")
If pos2 = 0 Then pos2 = Len(str) + 1
RetLineWord = Mid(str, pos + 1, pos2 - pos - 1)
End Function
You'll find VIP3R by:
msgbox RetLineWord(yourtext,2,4)
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Nov 3rd, 2000, 09:39 PM
#12
Thread Starter
Fanatic Member
Thanx
Is there a better code. Also I have two frames in on one page and I want to get the html of one of them! How do I do that?
Visual Basic 6.0
Visual C++ 5
Delphi 5

-
Nov 5th, 2000, 02:21 PM
#13
Thread Starter
Fanatic Member
Kedaman
Try your code with a string with over 20 lines or am html page, it's not working properly. Can u please reply soon!
Visual Basic 6.0
Visual C++ 5
Delphi 5

-
Nov 5th, 2000, 08:44 PM
#14
transcendental analytic
Hmm, dunno it works well but it's a bit slow for huge texts, i did an emulation:
Code:
Sub main()
For n = 1 To 105
For s = 1 To n / 2
d = d & "TEXT" & n & "," & s & " "
Next s
d = d & vbCrLf
Next n
Debug.Print RetLineWord(d, 100, 50)
End Sub
Function RetLineWord(ByVal str As String, linenum As Long, wordnum As Long) As String
Dim x&, pos&, pos2&
For x = 2 To linenum
pos = InStr(pos + 1, str, vbCrLf)
pos = pos + 1
Next x
For x = 2 To wordnum
pos = InStr(pos + 1, str, " ")
Next x
pos2 = InStr(pos + 1, str, " ")
If pos2 = 0 Then pos2 = Len(str) + 1
RetLineWord = Mid(str, pos + 1, pos2 - pos - 1)
End Function
What error did you get? which line?
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Nov 6th, 2000, 07:44 AM
#15
Thread Starter
Fanatic Member
When my text has spaces in between the lines, then the program stops right before the space! For ex:
Hi
This is VIP3R
I skipped One Line
It stop on "This is VIP3R"
It stops on the second line because there's a double space! Try it your self!
Visual Basic 6.0
Visual C++ 5
Delphi 5

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
|