Char: ConvertFromInt32

ConvertFromInt32

Converts a 32-bit signed integer value to a 16-bit signed integer as a character.



 Public Function ConvertFromInt32(
	  ByVal Value As Long ) As Integer

Parameters

Value
[ByVal] Long. The 32-bit signed integer value to be converted to a corrisponding 16-bit integer character.

Return Values

Integer -  A 16-bit signed integer character.

Remarks

The 16-bit result will be a binary equivalent of the first 16 bits of the Value parameter.

Exceptions

Exception Condition
ArgumentOutOfRangeException Value is outside the valid range of -32768 to 65535.

Examples

The following example demonstrates converting a range of 32-bit signed integer values to their corrisponding character represented by a 16-bit signed integer using ConvertFromInt32.

Public Sub Main()
    Convert 65
    Convert -1
    Convert 65535
    Convert -32768
    Convert 32768
End Sub

Private Sub Convert(ByVal c As Long)
    Dim Ch As Integer
    
    Ch = Char.ConvertFromInt32(c)
    
    Debug.Print CorString.Format("{0,6}(&h{0:X8}) converts to {1,6}(&h{1:X4})", c, Ch)
End Sub

' The example code produces the following output.
'
'        65(&h00000041) converts to     65(&h0041)
'        -1(&hFFFFFFFF) converts to     -1(&hFFFF)
'     65535(&h0000FFFF) converts to     -1(&hFFFF)
'    -32768(&hFFFF8000) converts to -32768(&h8000)
'     32768(&h00008000) converts to -32768(&h8000)

See Also

Project CorLib Overview

Class Char Overview

ConvertToInt32