Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

VB Constants in text strings

Posted on 2012-03-13
4
233 Views
Last Modified: 2012-03-14
I use Visual Basic for SQL applications.  Most of the queries are dynamic, lengthy, and complex.  In Visual Studio 2005, I was able to construct the SQL statements with immbeded VB constants (eg. vbLf, vbTab).  During debugging, I could then copy the string value and paste it into SQL Management Studio.  The vb constants gave a formatted layout in SQLMS.

As a simple example:
dim strSql as string = "select a, b, c " + vbLf + "from xyz"

In Visual Studio 2010, the vb constants are ignored or replaced with blanks.  As a result, the query in SQL is not formatted at all.  The same occurs when I paste into Notepad.  Therefore, the formatting is being lost during the Visual Studio copy, and not during the paste.  I've tried all variants of the copy.

This isn't a huge problem, but it seems it should be easy to do.  Any suggestions?

Thanks, Dave
0
Comment
Question by:SkyGuyDave
  • 2
4 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 37717663
This may not make any difference but + is used in C# for string concatenation and we use & in VB for concatenation though + works in most cases.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 37717666
Do you copy from the tool tip that shows the value when debugging? Did you try using the immediate window instead?
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 100 total points
ID: 37719624
I had the same problem. Instead of using ? strSQL, use this:

Debug.Print(strSQL)
0
 

Author Closing Comment

by:SkyGuyDave
ID: 37721410
Using Debug.Print() in the Immediate window worked perfectly.  Thanks, emoreau, for the solution.

Too bad it doesn't work from the "Copy" function from the tooltip, as it did in Visual Studio 2005.  That was really easy!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question