Use array operation string

zhaozj2021-02-16  52

If a large string needs to make some complex encryption or decryption operations or to perform alternatives to a particular character, it is not suitable to put it in a traditional String type variable. One is quite troublesome in the modification, and the second is also very slow.

Therefore, there is a need for a faster and efficient way.

Byte types can solve this problem very well (you can use byte. If you want to be compatible with ordinary TextBox display)

For example, I have to use a cycle to separately separate a character with a cycle, and the ASC function is separated by the MID. , Use Chr to restore it into TextBox. So if this string is large, you will find that the conversion speed will get slower and slower, and the last second is not a few characters (even if you have the refresh of Textbox during the conversion). However, if the operation is used in a BYTE type array.

For example, to "sample code" is a word. So please see the following code:

Dim Wordstring () AS BYTE

WordString = "Sample Code" 'BYTE Types can be well compatible with TextBox explicitly. It can also be very compatible with ordinary string storage mode

In this two sentences, it is equal to the four words of "sample code" into a string type variable. Different is that it is better than String variables. Because the operating array is quite flexible, it allows you to change the value of some of the race, without having to change the value of the entire variable. This is the String type variable cannot be replaced. And more benefits using the BYTE type group is completely compatible with the display of TextBox! Do not have any conversion at all, directly using code:

TextBox1.text = WordSting

The characters that are stored in this BYTE type array can be displayed.

This avoids the time that strings that are frequently stored in TEXTBOX in the string operation. Because we can completely make this array variable to make the TextBox in one time after the array is operated. The time saving time is huge.

转载请注明原文地址:https://www.9cbs.com/read-28126.html

New Post(0)