|
-
Oct 3rd, 2000, 06:03 PM
#1
Thread Starter
Addicted Member
im making a program that has alot to do with text replaces ment and im not good at all that stuff so can some one help me out . i got two question
1) How can i replace the text and then replace it with something else
ex
<title> hehehehehhehe </title>
<title> replace that </title> ' with out making a new title tag
2) how can i get the text that is inside the tags
ex
<title> hehehehhehehhehe </title>
teh title is heheheheheheheh
if any one anwser's just one it will be very nice i now this text stuff is hard thank you
-
Oct 3rd, 2000, 06:09 PM
#2
Addicted Member
2 functions
1) give the Replace function a try
2) give the InStr function a try
hope it helps
-
Oct 3rd, 2000, 06:13 PM
#3
Thread Starter
Addicted Member
maybe if i knew how to use them i whould and i thinkw hat im trying to do is not with the replace function because the title can have anytrhing in side the tag ex
<title> anything ins ide this </title>
<title> now what i want to replace </title>
WHat would we do with out Microsoft.
A lot more.
-
Oct 3rd, 2000, 06:53 PM
#4
This will get the text out of <TITLE> and </TITLE> (or whatever you specify)
Code:
Function GetText(sIn As String, sEnclosedIn As String, sEnclosedIn2 As String) As String
Dim StartPos As Integer, EndPos As Integer
StartPos = InStr(1, sIn, sEnclosedIn) + Len(sEnclosedIn)
EndPos = InStr(StartPos, sIn, sEnclosedIn2) - (Len(sEnclosedIn) + 1)
GetText = Mid(sIn, StartPos, EndPos)
End Function
Private Sub Command1_Click()
Dim MyString As String
MyString = "<TITLE>Text inside title</TITLE>"
Print GetText(MyString, "<TITLE>", "</TITLE>")
End Sub
-
Oct 3rd, 2000, 06:57 PM
#5
_______
<?>
Code:
Option Explicit
Private Sub Command1_Click()
Dim myString As String, temp1 As String, temp2 As String
myString = "<title> hehehehehhehe </title>"
temp1 = Left(myString, 7)
temp2 = Right(myString, 8)
myString = ""
myString = temp1 & "My Replacement" & temp2
MsgBox myString
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
-
Oct 3rd, 2000, 07:14 PM
#6
Thread Starter
Addicted Member
thanks guy and thank you HESAIDJOE alor because you heped me out both times
WHat would we do with out Microsoft.
A lot more.
-
Oct 3rd, 2000, 08:52 PM
#7
A little more, using Megatron's code:
Code:
Function GetText(sIn As String, sEnclosedIn As String, sEnclosedIn2 As String) As String
Dim StartPos As Integer, EndPos As Integer
StartPos = InStr(1, sIn, sEnclosedIn) + Len(sEnclosedIn)
EndPos = InStr(StartPos, sIn, sEnclosedIn2) - (Len(sEnclosedIn) + 1)
GetText = Mid(sIn, StartPos, EndPos)
End Function
Private Sub Command1_Click()
Dim MyString As String
MyString = "<TITLE>BIG TITLE STRING IN BETWEEN WORDS</TITLE>"
MyNewString = GetText(MyString, "<TITLE>", "</TITLE>")
Debug.Print Replace(MyString, MyNewString, "Let-me-squeeze-in-here")
End Sub
Just a little advancement using vb6's Replace function. Hope that helps a bit more.
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
|