|
-
How do I put quotation marks in a string
Do I have to write a separate public function to accomplish this? If so how would I go about it. Thanks for all the help.
-
Sorry forgot to mention this is VB 6, thanks
-
Did you try to just escape them? Like
"This is a string that reads \"This is a string\""
Dunno if this works in VB, but it's a convention among several other things.
------------------
/earth is 98% full ... please delete anyone you can.
"Manners are only needed between people, to keep their empty affairs in working order."
"The Once and Future King", T.H. White
-
Originally posted by lansdown:
Do I have to write a separate public function to accomplish this? If so how would I go about it. Thanks for all the help.
I don't know if this is exactly what you were looking for, but I just wrote a really quick VB6 program where you click on a box and it makes a string (with quotes in it) and then types it in a message box. Here is the code syntax:
Private Sub ClickMe_Click()
Dim strTest
strTest = "This is a string with some quotes: "", "", "", "" in it!"
MsgBox (strTest)
End Sub
As you can see, while you are writing the string, double-quotes "" can be used to represent single-quotes. Hope it helps.
------------------
Nick_B
ICQ: 1697810
P4 1.4 GHz
256 Megs PC800 RDRAM
GeForce2 Ultra
Win 2K
-
Thats close, but what I need to do is put the whole string in quotes. For example the string: "This is a string with some quotes: "", "", "", "" in it!", would actually be in quotes. I know that it is possible to do but I am still not sure how. Thanks for all the help so far.
-
Originally posted by lansdown:
Thats close, but what I need to do is put the whole string in quotes. For example the string: "This is a string with some quotes: "", "", "", "" in it!", would actually be in quotes. I know that it is possible to do but I am still not sure how. Thanks for all the help so far.
""That's all u need?""
------------------
I am crab, scoins is crap.
DHAHL3seasons GP:73 G:121 A:55 Pts:176 GWG:12 +/-:184
UWSWA6seasons GP:41 G:53 A:46 Pts:99 GWG:5 +/-:-25
MCBHL3seasons GP:14 G:20 A:8 Pts:28 GWG:4 +/-:19
uwcdc.com or monkis.com
-
Originally posted by lansdown:
Thats close, but what I need to do is put the whole string in quotes. For example the string: "This is a string with some quotes: "", "", "", "" in it!", would actually be in quotes. I know that it is possible to do but I am still not sure how. Thanks for all the help so far.
Dim strQuotes
strQuotes = """This string is in quotes"""
The first " starts the string, the second and third make the quote. At the end the double quotes make the quote you see and the final set of quotes ends the string. Ick...that explanation just sounds nasty, but hopefully the example will help enough.
------------------
Nick_B
ICQ: 1697810
P4 1.4 GHz
256 Megs PC800 RDRAM
GeForce2 Ultra
Win 2K
-
Hammerhead Shark
Will VB really figure that out???
In every language I've ever dealt with, ""hello"" will cause a compile error (unrecognized token or something), because the first starts it and the second ends it, so 'hello' is to be interpreted as a variable.
However, I'm pretty sure escaping is universal... e.g. \"text to appear in quotes\" ...with this you can also do:
dim myString As String
String = "\"text in quotes\""
MsgBox(myString)
------------------
I pity da foo
[This message has been edited by praxis (edited April 06, 2001).]
-
I am using the Microsoft VB 6.0 Development program and it does not allow double quotes within a string. Example strNew = ""String"" : will result in an error message because it doesn't like "" next to each other. I have tried spaces as well between the " but that does not seem to work either. I have read that quotes can be put in a string by using a "Built-In Function" but am not sure how to code it....
-
Sorry Nick_B I was not looking close enough to notice the """. That seems to work great, thanks tons. I will work on putting that in my code. Again thanks a lot for the help!!!!
-
Texan Dragon Moderator
Hey guys, Nick_B was right.
I just ran what he suggested, three quotation marks in a row both ending and begining, and it works. Here's my exact code in the Form_Load():
Dim MyVar
MyVar = """Come see me in the Immediate pane."""
Debug.Print MyVar
Like he said, the first quote opens the string. The next two quotes tell VB to output a single quotation mark.
It works. 
------------------
Baby of Edgewood @ birth (03/09/01, 12:34am)
6 lbs 7 ounces
18 inches long
perfectly healthy
Dragon of the OC Crusaders
Break the rules and you're snack food for this dragon...
-
Originally posted by Galen of Edgewood:
Hey guys, Nick_B was right.
I just ran what he suggested, three quotation marks in a row both ending and begining, and it works. Here's my exact code in the Form_Load():
Dim MyVar
MyVar = """Come see me in the Immediate pane."""
Debug.Print MyVar
Like he said, the first quote opens the string. The next two quotes tell VB to output a single quotation mark.
It works. 
Good to know my little bit of programming knowledge helped somebody :P
------------------
Nick_B
ICQ: 1697810
P4 1.4 GHz
256 Megs PC800 RDRAM
GeForce2 Ultra
Win 2K
-
Plugged it into my code and it worked perfectly. Took a little manipulating because I had more then one string, data and user input to incorporate into this, thanks for all the help couldn't have done it without ya.
-
Originally posted by lansdown:
Plugged it into my code and it worked perfectly. Took a little manipulating because I had more then one string, data and user input to incorporate into this, thanks for all the help couldn't have done it without ya.
No problem, glad to help.
------------------
Nick_B
ICQ: 1697810
P4 1.4 GHz
256 Megs PC800 RDRAM
GeForce2 Ultra
Win 2K
-
Ultra Great White Shark!!
hurray for the tripple quote.
------------------
www.geocities.com/richardginn/templatehtml -Come visit the Template HTML homepage
www.myeducational plan.com-come see my plan to fix the USA educational system. I hope this is sig legal. Major Site Design Update on July 18, 2006. On June 18, 2009 passed the 10,000 post mark. December 24, 2009: Major Theme change and 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
|
|