Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 248
  • Last Modified:

VB Constants in text strings

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
SkyGuyDave
Asked:
SkyGuyDave
  • 2
1 Solution
 
CodeCruiserCommented:
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
 
CodeCruiserCommented:
Do you copy from the tool tip that shows the value when debugging? Did you try using the immediate window instead?
0
 
Éric MoreauSenior .Net ConsultantCommented:
I had the same problem. Instead of using ? strSQL, use this:

Debug.Print(strSQL)
0
 
SkyGuyDaveAuthor Commented:
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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now