How can I store a double quote as a string in visual basic?
Double Quote as string
Started by Vswe, May 04 2009 11:03 AM
11 replies to this topic
#1
Posted 04 May 2009 - 11:03 AM
|
|
|
#2
Guest_Jordan_*
Posted 04 May 2009 - 11:26 AM
Guest_Jordan_*
You need to escape it:
MyString = "\"" str1 = "President Lincoln said \"Four score and seven years ago...\""
#3
Posted 04 May 2009 - 11:34 AM
Ok, Thanks alot. It were something I never thought about before and then when I now needed to use it, I just thought; How can this possible work?
Thanks again.
Thanks again.
#4
Posted 04 May 2009 - 11:37 AM
The thing is, it didn't work.
#5
Posted 04 May 2009 - 11:43 AM
Well I solved it myself:
Insetead of:
It was just to write:
And the string got the value "
A little bit strange perhaps.
Insetead of:
Dim MyString as string = ""
It was just to write:
Dim MyString as string = """"
And the string got the value "
A little bit strange perhaps.
#6
Guest_Jordan_*
Posted 04 May 2009 - 11:52 AM
Guest_Jordan_*
Very odd indeed. I wouldn't expect repeating an escapable char twice would escape it, but then again, this is Visual Basic.. :)
#7
Posted 04 May 2009 - 12:01 PM
hehe :D I wrote the correct solution before, but didn't even test if it worked since it looked completely wrong (It was just two empty strings between each other).
Edited by Vswe, 04 May 2009 - 12:03 PM.
misspelled
#8
Posted 05 May 2009 - 11:28 AM
Jordan said:
Very odd indeed. I wouldn't expect repeating an escapable char twice would escape it, but then again, this is Visual Basic.. :)
Yeah, that's how it's done in VB. Escape sequences don't work in VB. This problem comes up quite a lot in VBA in particular, where you are writing macros to concatenate data from various string fields.
#9
Guest_Jordan_*
Posted 05 May 2009 - 01:01 PM
Guest_Jordan_*
Just another reason VB sucks, IMO.
#11
Posted 06 May 2009 - 09:26 AM
Well that's kinda annoying. Which is one of the reasons I don't like VB. :D
Why can't you use C# for office macros?
Why can't you use C# for office macros?


Sign In
Create Account


Back to top









