Many of you will have noticed that there is both a Mid and a Mid$ function, as well as Left$, Right$, and a number of other functions. However, it is not obvious what the difference actually is. When you use the Mid function, it returns a string as a Variant data type. As you would normally save the result to a string, not a Variant, Visual Basic then has to convert the Variant into a string. When you use the Mid$ function, it returns a string in a String variable. This saves Visual Basic the trouble of converting the Variant to a String, and thus increases performance. When you perform long loops of code, using Mid, and the other string functions, this can make quite a difference. I have yet to find an instance when you would actually want the Mid statement to return a Variant, and not a String, so I am not sure why Microsoft have done this. To see a list of all the procedures that have a $ (string) version as well, open the object browser (F2), enter $ into the find box, and press Find. This will give you a list of about 25 procedures where this is the case.
Performance Issues
About the author
James Crowley
James first started this website when learning Visual Basic back in 1999 whilst studying his GCSEs. The site grew steadily over the years while being run as a hobby - to a regular monthly audien...
Interested in writing for us? Find out more.
Database books
-
Programming with Microsoft Visual Basic 2008
Programming with Microsoft Visual Basic 2008, Fourth Edition by the best-selling author, Diane Zak, is designed for a first course in programming. Using the most recent version of the software, Visual Basic 2008, this book teaches individuals how to ...
Database forum discussion
-
Required Every quarter data from sql automatically in below sql format
by jain.piyush831 (0 replies)
-
Is Your Data is Lost? Learn Online How TO Recover Your Data.
by dataempires (0 replies)
-
Executing a command line SELECT
by cyoung311 (0 replies)
-
Softaken Mac OLM to PST Migration Software
by albertcolin012 (0 replies)
-
MAX value of each column - HELP
by triparipr (0 replies)
Database podcasts
-
Stack Overflow Podcast: Podcast #45 – Keeping it Sharp
Published 7 years ago, running time 0h54m
Our guest this week is Eric Lippert – language architect extraordinaire and famous for all his work at Microsoft in developing their languages Eric joined Microsoft right out of college and was originally working on VB It’s time for everyone’s favorite game: Name the Worst Feature of that Microso.
Comments