Use the Line Continuation Character with Caution

Where NOT to use “_”:

1. SQL strings

Why? Because, during debugging, you may have to modify a SQL string because you need to add a field, or remove a field, correct a typo or any number of possibilities. For example, let’s say you have just typed in 50 parameters to get to a particular system state. You press OK and then you get a message box saying “3131 Syntax error in Where clause…”. You look at the SQL and you see an obvious error in a string connected with “_”. You correct the mistake then you get “This action will reset your project, proceed anyway?”. At this point you bang your head against the wall and re-enter the 50 parameters again.

It is much easier to use the following format:

 s = " SELECT * FROM abcTbl " & vbcrlfs = s & " WHERE fieldCDE = 'something' " & vbcrlfs = s & " ORDER BY fieldDEF "


This can be modified without the dreaded restart message and if you need to debug this, the formatted text will be readable in the immediate window, whereas continued text will show as a single unformatted long line. There is one caveat, which is that this way makes concatenating a string is less efficient and slower, but this usually doesn’t matter unless you are running it thousands of times. It does not affect SQL performance.

2. Remarks

 'This is a long remark.... more stuff _continuing remark _even more remarks (don't ever do this)


Again, if you edit this remark at run time, the system will respond with”This action will reset your project…”. There is absolutely no reason this should occur. Use the block comment with the apostrophe character instead.

Also, you don’t need to continue a line if your screen is wide enough to see the entire line anyway. Since VB now defaults to the MDI IDE, consider returning to the SDI environment. The MDI environment has the peculiarity that if one window is maximized, all are now maximized and none of the hotkeys work (e.g. ctrl-R for the project explorer). Also, the docking feature causes the code window width to be diminished when windows dock side by side. Under menu Tools/Options/Advanced, turn on the “SDI design environment” option, and under the “Docking” tab, turn off ALL the docking. Learn the few basic hotkeys in the SDI environment to be able to navigate much more rapidly and you will have the widest possible editing area (FYI: ctrl-R, ctrl-G, F4, F7, and shift-F7 brings up the project exlorer, immediate window, properties window, form code, and form design windows respectively).

Basically, the “_” character should be used judiciously and not just to make neat columns.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

The Latest

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS

homes in the real estate industry

Exploring the Latest Tech Trends Impacting the Real Estate Industry

The real estate industry is changing thanks to the newest technological advancements. These new developments — from blockchain and AI to virtual reality and 3D printing — are poised to change how we buy and sell homes. Real estate brokers, buyers, sellers, wholesale real estate professionals, fix and flippers, and beyond may