Please enable JavaScript to view this site.

thinBasic Help Manual

* * HELP & MANUAL PREMIUM PACK 4 DEMO VERSION * *

This documentation was styled with a demo skin from the Premium Pack 4 add-on for Help & Manual. The contents of the skin are encrypted and not configurable. You can only publish HM projects with this skin. You cannot edit it or change it.

This version is copyright and may only be used for local testing purposes. It may not be distributed.

Please purchase the full version of the Premium Pack to get the configurable skins and remove this notice. The package will also include the Toolbox configuration utility for Premium Pack skins.

 

Description

 

Return the UTF-8 code (0 to 65536) of the specified character in a string.

 

Syntax

 

y = ASC(StringExpression [, position])

 

Returns

 

Number

 

Parameters

 

Name

Type

Optional

Meaning

StringExpression

String

No

A string expression from which to extract the code.

Can be an ASCII string or an UTF-8 string.

Position

Number

Yes

Position in chars inside string_expression from which to extract the code.

If position is not specified, the first position is taken.

If position is negative ASC counts from the end of the string.

If position is zero or greater than the length of the string -1 is returned

 

Remarks

 

Restrictions

 

See also

 

String Handling, CHR$,

 

Examples

 

'---ASC can be used to avoid some MID$ operations. For example:

char = ASC(Mid$(MyString, Position, 1))

'---is equivalent to ...

char = ASC(MyString, Position)

 

 

Thanks to Abraxas for the following script example

' Usage of the ASC Instruction example

' Return Values of a string. Will show a box with String to check

'

' HELLO

'

'Current Char H Value 72

'Current Char E Value 69

'Current Char L Value 76

'Current Char L Value 76

'Current Char O Value 79

 

Dim MyString  As String VALUE = "HELLO"

Dim sMsg      As String

Dim StrPos    As Long

Dim CharVal   As Byte

 

sMsg = "String to check " & $CRLF & $CRLF & MyString & $CRLF & $CRLF

 

For StrPos = 1 To Len(MyString) '---Loop for the length of the string

  CharVal = ASC (MyString,StrPos)

  sMsg += " Current Char " & Mid$(MyString,StrPos,1) & " Value " & CharVal & $CRLF

Next

 

MSGBOX 0, sMsg

 

 

Created with Help+Manual 8 and styled with Premium Pack Version 4 © by EC Software