Chr Function

Geeft het teken dat overeen komt met de gespecificeerde tekencode terug.

Syntaxis:

Chr[$](expression As Integer) As String

Geretourneerde waarde:

String

Parameters:

Expression: a numeric expression that represents a valid 8-bit ASCII value (0-255) or a 16-bit Unicode value. (To support expressions with a nominally negative argument like Chr(&H8000) in a backwards-compatible way, values in the range −32768 to −1 are internally mapped to the range 32768 to 65535.)

warning

When VBA compatibility mode is enabled (OPTION VBASUPPORT 1), Expression is a numeric expression that represents a valid 8-bit ASCII value (0-255) only.


De Chr$-functie wordt vaak gebruikt om speciale stuurcodes naar een printer of andere uitvoerbron te zenden. U kunt de functie ook gebruiken om aanhalingstekens in een tekenreeks in te voegen.

Foutcodes:

5 Ongeldige aanroep van procedure

6 Overloop

note

An overflow error will occur when VBA compatibility mode is enabled and the expression value is greater than 255.


Voorbeeld:


        Sub ExampleChr
            ' Dit voorbeeld voegt een apostrof (ASCII waarde 34) in een tekenreeks in.
            MsgBox "A "+ Chr$(34)+"short" + Chr(34)+" trip."
            ' De afdruk verschijnt in het dialoogvenster als: Een "korte" trip.
        End Sub