|
-
May 13th, 2001, 07:16 AM
#1
Thread Starter
Junior Member
Strings - UCase and LCase (with HTML tags)
Ok, so heres the problem:
I am in the process of making a HTML editor, and I have a tool which (at the moment) converts tag case to uppercase or lowercase. The only problem is it also converts the attributes as well, which I don't want. Does anyone know how to ignore the attributes and change the case for the rest of the tag? I have included the source code that I am currently using below (for uppercase).
Oh, and btw, I'm a newbie, so plz give me some code (or tell me where I can find some) rather then tell me what vb function to use.
Thanks,
Tom
[email protected]
Here's the current code:
Code:
Sub TagUCase()
Dim txt As String
Dim tag_open As Integer
Dim tag_close As Integer
On Error GoTo ErrorHandler
rchEditor.Visible = False
Screen.MousePointer = vbHourglass
txt = rchEditor.Text
tag_close = 1
Do
tag_open = InStr(tag_close, txt, "<")
If tag_open = 0 Then Exit Do
tag_close = InStr(tag_open + 1, txt, ">")
If tag_open = 0 Then tag_close = Len(txt)
rchEditor.SelStart = tag_open - 1
rchEditor.SelLength = tag_close - tag_open + 1
rchEditor.SelText = UCase(rchEditor.SelText)
rchEditor.SelStart = 0
Loop
rchEditor.Visible = True
Screen.MousePointer = vbNormal
rchEditor.SetFocus
ErrorHandler:
rchEditor.Visible = True
Screen.MousePointer = vbNormal
Exit Sub
End Sub
-
May 13th, 2001, 11:58 AM
#2
Frenzied Member
This converts the tag only
Code:
Private Sub Command1_Click()
Dim iPos As Integer
Dim sTag As String
Dim sTagHolder
sTag = Text1.Text
iPos = InStr(2, sTag, Space(1))
sTagHolder = Split(sTag, Space(1))
sTagHolder(0) = UCase(sTagHolder(0))
sTag = Join(sTagHolder, Space(1))
Text1.Text = sTag
End Sub
-
May 13th, 2001, 01:10 PM
#3
Frenzied Member
This code will convert the atributes to uppercase but not the attribute value. for example
<img src="image.gif">
to
<IMG SRC="image.gif">
Here is the function just pass it the tag
Code:
Here is the Function
Function ConvertHTMLTags(ByVal HTMLTAG) As String
Dim sTag As String
Dim i As Integer
Dim iLen As Integer
sTag = HTMLTAG
iLen = Len(sTag)
For i = 1 To iLen
If Mid(sTag, i, 1) = """" Then
ipos = InStr(i + 1, sTag, """")
Do Until i = ipos + 1
If i > iLen Then
i = i - 1
Exit Do
Else
stagholder = stagholder & Mid(sTag, i, 1)
End If
i = i + 1
Loop
End If
stagholder = stagholder & UCase(Mid(sTag, i, 1))
Next
ConvertHTMLTags = stagholder
End Function
Last edited by jjortiz; May 13th, 2001 at 01:17 PM.
-
May 13th, 2001, 01:14 PM
#4
Frenzied Member
You can also check in the following way. Start at the first = sign and loop till you get to the first space. Just in case someone did not use quotation marks.
-
May 13th, 2001, 01:40 PM
#5
Thread Starter
Junior Member
Thanks alot for this, I'll try it out and report back if I have any problems.
Cheers,
Tom
[email protected]
-
May 14th, 2001, 01:25 PM
#6
Thread Starter
Junior Member
Well it kinda worked, but it struggles with large files, and does things like:
Or it just returns a overflow error.
Apart from that it works fine (although I did have to modify it a bit).
Oh and btw, I don't suppose any of you have Dreamweaver UltraDev versions 3 or 4 do you? I just need to know a few things about it.
Cheers,
Tom
[email protected]
-
May 14th, 2001, 06:34 PM
#7
Frenzied Member
That snippet of code was written very quickly. I will take a look at it again and then revise it.
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
|