|
-
Sep 30th, 2000, 02:40 PM
#1
Thread Starter
Member
Hi
Find & Replace text in a textbox.
Has any of you done this. I tried "InStr" but I don't know
how it works.
Hope you can help
Chris
Christian Davidsen
If you go to sleep with an itchy
ass, you wake up with smelly fingers.
-
Sep 30th, 2000, 02:45 PM
#2
_______
<?>
dim x as string
x = text1.text
x = replace(x,"whatword","replacement")
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Sep 30th, 2000, 02:45 PM
#3
Fanatic Member
Look up msdn.microsoft.com for information on instr. Look here: Microsoft Visual Studio Documentation-->VB Documentation-->Reference-->Language Reference-->Functions-->I-->Instr
-
Sep 30th, 2000, 02:46 PM
#4
Fanatic Member
<!>
HeSaidJoe, I didn't see your post.
-
Sep 30th, 2000, 02:52 PM
#5
_______
<?>
No problem
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Sep 30th, 2000, 02:55 PM
#6
Thread Starter
Member
:-)
Thanks for the replies
Best Regards,
Chris Davidsen
Christian Davidsen
If you go to sleep with an itchy
ass, you wake up with smelly fingers.
-
Sep 30th, 2000, 03:22 PM
#7
Thread Starter
Member
hmmmm
This code does not compute
VB reject's the word "replace" in the code
dim x as string
x = text1.text
x = replace(x,"whatword","replacement")
Is there something wrong with this code?
Chris
Christian Davidsen
If you go to sleep with an itchy
ass, you wake up with smelly fingers.
-
Sep 30th, 2000, 03:26 PM
#8
_______
<?>
Shoot..you must not have VB6
Tested this but if you hav VB5 or 4 it won't work for you
Code:
Option Explicit
Private Sub Command1_Click()
Dim x As String
x = "Help me with whatword in this sentence"
x = Replace(x, "whatword", "My new Word")
MsgBox x
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Sep 30th, 2000, 03:32 PM
#9
_______
<?>
Code:
'this works in VB5 for search and replace
Option Explicit
Option Compare Text
'[begin of code]
'Author: John Percival
'Origin: http://www.vb-world.net/tips/tip110.html
'Purpose: A Find-and-Replace function for VB5 users
'Version: VB5+
'function to do the work
Public Function replaceall(searchstring As String, _
findstring As String, replacestring As String) As String
Dim curpos As Long
curpos = 1
Do
curpos = InStr(curpos, searchstring, findstring)
searchstring = Left$(searchstring, curpos - 1) & _
replacestring & Right$(searchstring, Len(searchstring) _
- curpos - Len(findstring) + 1)
Loop Until InStr(searchstring, findstring) = 0
replaceall = searchstring
End Function
'call to get the work done
'x = string to be searched
'y = what to search for
'z = what to replace it with
Private Sub Command1_Click()
Dim x As String, y As String, z As String
x = "What in the world are we Searching for here, anyway?"
y = "Searching for"
z = "Replacement Value"
Call replaceall(x, y, z)
MsgBox x
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
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
|