VB in the string function is more, also more convenient, do not introduce each. This article is mainly about string-related
Convert function to do some summary. The functions of string conversions are:
Str () and Val () are used to convert strings and numbers to each other;
CHR () and ASC () are used for mutual conversion of strings and ASCII codes;
CHRW () and ASCW () are used for conversion between Unicode codes and Chinese;
The Format () function is a very versatile function that is very powerful.
The first two pairs and the format () function are often used in these functions, and here are just a few simple examples of the first two pairs:
(1) MyString = Str (-459.65) ' return '-459.65 '.
MyString = Str (459.001) ' returns ' 459.001 '.
(2) myvalue = Val ("2 45 7") ' returns 2457.
MyValue = Val ("57") ' returns 24.
(3) MyChar = CHR (97) ' Return a.
MyChar = Chr (37) ' returns%.
(4) MyNumber = ASC ("Apple") ' returns 65.
MyNumber = ASC ("a") ' returns 97.
The Format function is very powerful, so you can look at the MSDN instructions. This article focuses on the third pair of functions, which is often overlooked by the pair of functions. When I developed SMS, I started with the text mode, and later changed to PDU mode because of the Chinese version. There are three types of PDU modes available: 7-BITS,8-BITS,UCS2. The first two are table complex, involving the design of the coding function, here is not much to say, I use the UCS2 code, It is found that the PDU string can be encoded and decoded as long as the third pair function is used. The use of the function is identical to the second pair, and here are some examples (the following code is obtained from the VB Immediate Window):
? ASCW ("Medium")
20013
? AscW ("Fruit")
26524
? ASCW ("E")
101
? ChrW (101)
E
? ChrW (26589)
Tuo
In the ChrW () and ASCW () functions, the ASCII is still treated in the same way as Chr () and ASC (). These are just a few of the things I have done with these functions, and I hope to play a role.
VB string and number mutual conversion function