Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > Using " in a string?


Reply
 
Thread Tools Display Modes
  #1  
Old 03-09-2007, 12:16 PM
Necrowizard Necrowizard is offline
Regular
 
Join Date: Aug 2004
Posts: 84
Default Using " in a string?


Hi,

Im wondering, how to i put a " thing in a string?
like

text1.text = ("Install path = "C:\windows"")


If i use that tho, it will say "Error: Expected )" soo...


Thanks

Gr. Ron
Reply With Quote
  #2  
Old 03-09-2007, 12:21 PM
ElderKnight ElderKnight is offline
Senior Contributor

Forum Leader
 
Join Date: Oct 2003
Location: Central Florida
Posts: 1,205
Default

Code:
Text1.Text = "Install path = ""C:\windows"""

Inside the delimiting quote marks, it takes a double " to generate a single ".
__________________
-- D.J.

I do not endorse any items advertised within this frame, and regret that the viewer is subjected to such.
Reply With Quote
  #3  
Old 03-10-2007, 12:28 AM
DougT's Avatar
DougT DougT is offline
Ultimate Antique

Administrator
* Expert *
 
Join Date: Sep 2005
Location: Maldon,Essex, UK
Posts: 3,939
Default

You could also use
Code:
Text1.Text = "Install path = " & Chr(34) & "C:\windows" & Chr(34)
I think it's a bit easier to read (well with my eyes it is ), but it is less efficient
__________________
semel insanivimus omnes
S Data in context = Information, S Information in context = Knowledge, S Knowledge in context = Experience
S Experience in context = Wisdom= Data
Reply With Quote
  #4  
Old 03-12-2007, 08:39 AM
ElderKnight ElderKnight is offline
Senior Contributor

Forum Leader
 
Join Date: Oct 2003
Location: Central Florida
Posts: 1,205
Default

Quote:
Originally Posted by DougT View Post
. . .

I think it's a bit easier to read . . .

And, I agree. In fact, I don't like all that Chr$() stuff all over the place, so I'll usuallly assign

Code:
Q$ = Chr$(34)

And use that.
You can even define a left quote (Lq$ = Chr$(34)) and a right quote (Rq$ = Chr$(34)), even if the value is the same, to help you keep track of 'em.

Code:
Print #1, Lq$ & "Look out," & Rq$ & " he said, " & Lq$ & "There it is!" & Rq$

That must violate most rules of style, but it helps.
__________________
-- D.J.

I do not endorse any items advertised within this frame, and regret that the viewer is subjected to such.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->