|
-
Aug 14th, 2000, 08:24 PM
#1
Thread Starter
Member
couldn't find this in the documentation anywhere (I hate MSDN):
How do you escape quotes in a string? e.g. in other languages you can do "\"" or "'" or """" to end up with a single quote. How is this accomplished in VB? (I really don't want to use Char(), which is a serious pain in the rear)
Thanks,
--Josh
-
Aug 14th, 2000, 08:36 PM
#2
Fanatic Member
use Double Quotes, ie.
John "Billy Bones" Smith is the man!
would be
Code:
"John ""Billy Bones"" Smith is the Man!"
Hope this helps
GWDASH
[b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]
-
Aug 14th, 2000, 08:42 PM
#3
Frenzied Member
You can use """ to do it, unfortunatley you can't do it inside a long string something like this
Code:
MsgBox "Sam Say's " & """ & "Hello" & """
doesn't work
If you want to incorparate it into a long string the best thing to do is to use a constant put in a standeard module
Code:
Public Const Q As String = """
and then you can do something like
Code:
MsgBox "Sam Say's " & Q & "Hello" & Q
-
Aug 14th, 2000, 08:58 PM
#4
I like to use the Chr$ function:
Code:
Private Sub Form_Load()
MsgBox "Hello " & Chr$(34) & "Sam" & Chr$(34) & " if that is your real name ;)"
End Sub
[Edited by denniswrenn on 08-14-2000 at 10:02 PM]
-
Aug 14th, 2000, 09:59 PM
#5
Thread Starter
Member
hmmm well my problem is that I'm messing with lots of HTML, so there are a lot of quotes being bandied about. For instance:
I've got to do a whole bunch of substitutions along the likes of:
Code:
Replace(IMWnds(i).nHTML, "<!--", "</FONT><FONT COLOR=""#000000"" SIZE=1>", 1, -1, vbTextCompare)
Can I do it with double quotes like so?
In perl I'd just do:
Code:
"</FONT><FONT COLOR=\"#000000\" SIZE=1>"
PLEASE tell me I don't have to do:
Code:
Dim sReplace As String
sReplace = "</FONT><FONT COLOR=" & Char(34) & "#000000" & Char(34) & "SIZE=1>"
Replace(IMWnds(i).nHTML, "<!--", sReplace, 1, -1, vbTextCompare)
I'm beginning to see why people shun VB in favor of more powerful/yntactically nicer languages...
-
Aug 14th, 2000, 10:11 PM
#6
Thread Starter
Member
answered my own question with a little testing:
Code:
IMWnds(i).nHTML = Replace(IMWnds(i).nHTML, "<!--", "</FONT><FONT COLOR=""#000000"" SIZE=1>", 1, -1, vbTextCompare)
IMWnds(i).nHTML = Replace(IMWnds(i).nHTML, "-->", "", 1, -1, vbTextCompare)
IMWnds(i).nHTML = Replace(IMWnds(i).nHTML, """>:</FONT>", """ SIZE=3>:</FONT>", 1, -1, vbTextCompare)
IMWnds(i).nHTML = Replace(IMWnds(i).nHTML, "</BODY></HTML>", "", 1, -1, vbTextCompare)
Not the most readable, but it works.
Thanks,
--Josh
http://aimlog.sourceforge.net
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
|