VBS Script Character Functions Reference And Printable Functions VBS Script

 

Provided here for your reference (And mine) is a chart listing the non-printable Control Character Functions - Chr() - and a VBS Script To Create A Microsoft Excel Spreadsheet Of Printable Character Functions found at the end of this post.

 

When creating VBS scripts the Chr(x) where x is the Character Code Number returns the character associated with the specified ANSI character code as in:

 

Wscript.Echo Chr(34), Chr(49), Chr(43), Chr(49), Chr(61), Chr(50), Chr(34)

 

Which is the equivilent of: Wscript.Echo "1 + 1 = 2"

 

The VBS script found below at the end of this post when executed will create an excel spreadsheet that you can save for your reference to allow you to find the Chr function needed to programmatically perform a specific operation or task such as appending quotation marks (34) or inserting a blank space (32) into your VBS scripts.

 

Non Printable Control Characters

 

Decimal

Glyph

00

Null character

01

Start heading

02

Start text

03

End text

04

End of transmission

05

Enquiry

06

Acknowledge

07

Bell

08

Backspace

09

Horizontal tab

10

Line Feed

11

Vertical tab

12

Form feed

13

Carriage return

14

Shift out

15

Shift in

16

Data link escape

17

Device control one (XON)

18

Device control two

19

Device control three (XOFF)

20

Device control four

21

Negative

22

Synchronous idle

23

End of transmission block

24

Cancel

25

End of medium

26

Substitute

27

Escape

28

File separator

29

Group separator

30

Record separator

31

Unit separator

32 – 126

Printable Characters (VBS Script Below)

127

Delete

 

Decimal 10 and 13 in the chart above are also commonly used in VBS scripting.

 

Decimals 65 to 90 are reserved for upper case letters A – Z respectively.

Decimals 97 to 122 are reserved for lowercase letters a –z respectively.

 

VBS Script To Create A Microsoft Excel Spreadsheet Of Printable Character Functions

 

Set objExcel = CreateObject("Excel.Application")

objExcel.Visible = True

objExcel.Workbooks.Add

intRow = 2

 

objExcel.Cells(1, 1).Value = "CHR Function"

objExcel.Cells(1, 2).Value = "Character Set"

 

'32 - 126 Are Printable Characters

For i = 32 to 126

 

objExcel.Cells(intRow, 1).Value = "Chr(" & i & ")"

objExcel.Cells(intRow, 2).Value = Chr(i)

intRow = intRow + 1

Next

 

objExcel.Range("A1:B1").Select

objExcel.Selection.Interior.ColorIndex = 19

objExcel.Selection.Font.ColorIndex = 11

objExcel.Selection.Font.Bold = True

objExcel.Cells.EntireColumn.AutoFit

 

MsgBox "Done"

 

 

 

Published Wednesday, September 24, 2008 10:35 AM by dhite
Filed under: ,

Comments

No Comments