[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
VBHowTo_MidStatement
Did you know you can use Mid$ not only as a function but also as a Statement? Visual Basic 6 has a special implementation for Mid$ so it can be used as a statement to paste a string within an already existing string, without having to reallocate memory, making it much faster than string addition using string1 & string2
You can also ommit the length if you wish:
When the string you are trying to insert is larger than the length of the string it is cut off:
Using the Mid$ statement can be much faster when working with large strings and can be used to highly optimize code.
A good article about how to use this to optimize 'string concatenation' is found on MSDN Library
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
VBHowTo_MidStatement
Did you know you can use Mid$ not only as a function but also as a Statement? Visual Basic 6 has a special implementation for Mid$ so it can be used as a statement to paste a string within an already existing string, without having to reallocate memory, making it much faster than string addition using string1 & string2
sText = "Did you know about Mid$?" Mid$(sText, 19, 4) = "this" - sText - "Did you know about this?"
You can also ommit the length if you wish:
sText = "Did you know about Mid$?" Mid$(sText, 19) = "this" - sText - "Did you know about this?"
When the string you are trying to insert is larger than the length of the string it is cut off:
sText = "Did you know about Mid$?" Mid$(sText, 14, 22) = "it cuts off the string?" - sText - "Did you know it cuts off"Here too, the Length can be omitted.
Using the Mid$ statement can be much faster when working with large strings and can be used to highly optimize code.
A good article about how to use this to optimize 'string concatenation' is found on MSDN Library
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
