|
-
February 24th, 2000, 08:19 PM
#1
Please help me with this function!!
i would like to make a function that inserts opening and closing html tags around selected text in a textbox (it wraps the tags around a selected text)
the function would start like
public function wrapTags(tag, additionalstuff, textbox)
'Tag is the HTML tag we want to wrap around selected text
' on the start of the selected text it would add
textbox.seltext = "<" & tag & " " & additionalstuff & ">"
' and on the end of the text it would add
textbox.seltext = "</" & tag & ">"
i would call the function like this:
call wrapTags("HEAD", "bgcolor='black'", "frmMDI.ActiveForm.Text1")
PLEEEEEAAAAASEEEE HELP ME OUT!!
---------------------
~:{Decayed}:~
http://www.q3seek.com
-
February 24th, 2000, 10:04 PM
#2
Re: Please help me with this function!!
It seems to me that you already got the logic and code for your requirement.
What kind of help you want?
I would suggest that go ahead and complete the code and test it. You already solved your problem.
-
February 25th, 2000, 02:30 AM
#3
Re: Please help me with this function!!
your code:
textbox.seltext = "<" & tag & " " & additionalstuff & ">"
' and on the end of the text it would add
textbox.seltext = "</" & tag & ">"
in your second line you overwrite the seltext property.
shouldn't it rather look like:
dim strText as string
strText = "<" & tag & " " & additionalstuff & ">"
strText = strText & "</" & tag & ">"
textbox.seltext = strText
-
February 25th, 2000, 03:15 AM
#4
Re: Please help me with this function!!
Lothar's code is probably what you need, but you say you want to wrap HTML tags around the selected part of the textbox. Try this little refinement in Lothar's code (i hope you don't mind Lothar):
dim strText as string
strText = textbox.seltext
strText = "<" & tag & " " & additionalstuff & ">" & strText
strText = strText & "</" & tag & ">"
textbox.seltext = strText
-------------------------
Nick A.
-
February 25th, 2000, 03:38 AM
#5
Re: Please help me with this function!!
I just want to make 1 note, you are using a function, this returns a value, in your code you use call wrapTags("HEAD", "bgcolor='black'", "frmMDI.ActiveForm.Text1"), this returns a value, wich you do not assing to a variable, this will give an error. In your function, you also don't set the value the function returns, my advice is to change your funtion into a sub, so your code would be:
public sub wrapTags(tag, additionalstuff, textbox)
' Tag is the HTML tag we want to wrap around selected text
' on the start of the selected text it would add
textbox.seltext = "<" & tag & " " & additionalstuff & ">"
' and on the end of the text it would add
textbox.seltext = "</" & tag & ">"
end sub
' when calling, omit the braces ()
call wrapTags text1.seltext, "bgcolor='black'", "frmMDI.ActiveForm.Text1"
or.. you can use it as a function, and your code would look like this
public function wrapTags(tag, additionalstuff)
' Tag is the HTML tag we want to wrap around selected text
' on the start of the selected text it would add
' I left textbox out of the function
wrapTags = "<" & tag & " " & additionalstuff & ">"
' and on the end of the text it would add
wrapTags = "</" & tag & ">"
end function
' the call would then be
text1.seltext = wrapTags(text1.seltext, "bgcolor='black')
Tom Cannaerts
[email protected]
The best way to escape a problem, is to solve 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
|