I need help with writing || operator

  • Thread starter Thread starter Al
  • Start date Start date
A

Al

I do not have the || symbol for the "OR" operator on my keyboard. Is there a
way to type it in the code instead of copy and paste from the internet?
Thanks
Alaa
 
I do not have the || symbol for the "OR" operator on my keyboard. Is there a
way to type it in the code instead of copy and paste from the internet?
Thanks
Alaa

Well... The only alternative I can think of is to use the | chars alt+keycode
sequence. You can figure it out if you use the charmap utility in system
tools. Select the font your using, and then find out the value of the
character. I use consolas, and it shows the character code as U+007C. That's
124 decimal.

So, I can type a+124 (using the numeric keypad) in notepad and I get a |.
 
Al said:
I do not have the || symbol for the "OR" operator on my keyboard. Is there
a
way to type it in the code instead of copy and paste from the internet?

There is probably some "hidden" way to get it in your keyboard. For
example, on a Spanish keyboard you get the "pipe" ("|") symbol by means of
Right-Alt+1. (The "logical OR" ("||") is made out of two consecutive pipes).

Another trick is to use ALT 124 (press and hold the ALT key, then type
124 on the numeric keypad, then release ALT).

Otherwise, you can open the "Character Map" program from Start -> All
Programs -> Accessories -> System Tools. This program lets you select any
character and copy it into the Clipboard.

Another alternative is to add a second keyboard configuration to your
computer from Control Panel. You can assign a keyboard combination to change
the keyboard layout, and also dislay a small two-letter code in your taskbar
that shows the currently selected keyboard and also lets you change it.
 
Al said:
I do not have the || symbol for the "OR" operator on my keyboard. Is there
a
way to type it in the code instead of copy and paste from the internet?
Thanks
Alaa

What kind of keyboard do you have?

The character | may be broken in the middle so that it looks like two short
lines instead of one long one.
 
I do not have the || symbol for the "OR" operator on my keyboard. Is there
a
way to type it in the code instead of copy and paste from the internet?

[These directions are based on Visual Studio 2005.]

Go to Tools | Macros | Macros IDE (or press Alt+F11). There should be a root
node in the Project Explorer called MyMacros. If there's no module beneath
in, right-click it and choose Add Module. Then paste the following code into
it:

Sub InsertPipe()
Dim textSelection As EnvDTE.TextSelection
textSelection = CType(DTE.ActiveDocument.Selection(),
EnvDTE.TextSelection)
textSelection.Text = "|"
End Sub

Save it and close the macro editor. Back in the VS IDE, right-click a
toolbar and choose Customize. Then click the Keyboard button. In the "Show
commands containing text" box, type "InsertPipe". The list box below should
be populated with that macro (and probably nothing else). Now pick and
assign a shortcut key. I used Ctrl+Shift+P, which was already assigned to
Run Temporary Macro, but I never use that so it was a good hijack. Hit OK as
needed.

Now you can just press your shortcut key in the editor and get your pipe.

(On second thought, why not use Ctrl+Shift+\ as the shortcut? It's not
mapped to anything in my system and on my keyboard the pipe is right above
the backspace, so it's almost like actually having the character there.)
 
Back
Top