|
-
Feb 19th, 2000, 05:34 PM
#1
Thread Starter
New Member
i made a word processor, and now i need want to put a "search" feature on it. How do i code it?
so far i have this:
FindOver = False
SearchPos = 0
FindText Text, Find
Text.SelStart = SelTextFrom
Text.SelLength = SelTextTo
but, that doesn't work....
can anyone help me????
thanks, kirkhammet
-
Feb 19th, 2000, 05:43 PM
#2
Conquistador
Originally posted by kirkhammet:
i made a word processor, and now i need want to put a "search" feature on it. How do i code it?
so far i have this:
FindOver = False
SearchPos = 0
FindText Text, Find
Text.SelStart = SelTextFrom
Text.SelLength = SelTextTo
but, that doesn't work....
can anyone help me????
thanks, kirkhammet
how's this for quick service?
try:
Code:
dim findThis as string
findthis = myform.findTextBox.text
FindOver = False
SearchPos = 0
FindText Text, Find
Text.SelStart = 0
Text.SelLength = len(findthis)
if text.seltext = findthis then
msgbox "String Found"
if this doesn't work, email me your program and i will fix it for you!

------------------
david
Teenage Programmer
-
Feb 19th, 2000, 06:03 PM
#3
Thread Starter
New Member
i need to know what the code for the sub "FindText" is ... and i need to know what goes in the parenthesis
kirk
-
Feb 19th, 2000, 06:45 PM
#4
So Unbanned
I made a function to do this!
here ya go:
Code:
Public Function FindText(TextBox As TextBox, TextString As String)
TextBox.SetFocus
If InStr(TextBox.Text, TextString) > 0 Then
TextBox.SelStart = InStr(TextBox.Text, TextString) - 1
TextBox.SelLength = Len(TextString)
Else
MsgBox "Text '" & TextString & "' not found!", 16, "Error"
End If
End Function
Private Sub Command1_Click()
FindText Text1, "Hello"
End Sub
If the text is found it HighLights it. If not you get an error message that says it's not found!
------------------
DiGiTaIErRoR
VB, QBasic, Iptscrae, HTML
Quote: There are no stupid questions, just stupid people.
[This message has been edited by DiGiTaIErRoR (edited 02-20-2000).]
-
Feb 20th, 2000, 06:14 AM
#5
Thread Starter
New Member
good one!, but i need to know how you make it work when you input the string you want it to search for. i.e. you type in a word, and hit search... then it finds it. how do you do that?
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
|