![]() |
can variable names end with a $ or &
Can vba variable names end with a $ or &? And if they can, is there
something special about them? I see rules that state: "The name can't contain a space or any of the following characters: . ! # $ % & @" But - here I am looking at at a program that has them... Thank you. |
can variable names end with a $ or &
Can vba variable names end with a $ or &? And if they can, is there
something special about them? I see rules that state: "The name can't contain a space or any of the following characters: . ! # $ % & @" But - here I am looking at at a program that has them... Thank you. Those are 'Type' symbols used as shortcuts for typing 'As <datatype'. They can be used to Dim/declare a variable but won't be needed when using the variable in code... Dim sData$ '//string Dim lLastRow& '//long Dim n% '//integer ..and so on... sData = "MyName": lLastRow = 500: n = 0 ...uses the variables without the 'Type' symbols. Note that there are some structs that do not permit using 'Type' symbols, and VB will let you know when you try using them inappropriately. Note that some functions also implement the symbols. Some that come to mind for string functions are... Mid$() Left$() Right$() -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion |
can variable names end with a $ or &
Here's a complete list of the symbols and their respective data type...
% integer & long ! single-precision floating point # double-precision floating point $ string @ currency -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion |
can variable names end with a $ or &
GS wrote:
Note that some functions also implement the symbols. Some that come to mind for string functions are... Mid$() Left$() Right$() Look at pretty much any code I post that manipulates strings. I always include the $ in the function's name. (Habit from the QB days, plus other BASICs still require them.) -- - What's the winning lottery numbers? - If I knew that, I wouldn't be working here! |
can variable names end with a $ or &
GS wrote:
Note that some functions also implement the symbols. Some that come to mind for string functions are... Mid$() Left$() Right$() Look at pretty much any code I post that manipulates strings. I always include the $ in the function's name. (Habit from the QB days, plus other BASICs still require them.) Yeah.., me too! I got into the habit of using the symbols when defining vars just for the brevity. I've been posting a lot of replies that use them just out of habit. I'm thinking if people understand what they mean then so be it, but if not then it probably doesn't matter anyway since those would be looking for 'turnkey' solutions they wouldn't understand in the 1st place<g! -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion |
All times are GMT +1. The time now is 12:18 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com