Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default 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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default 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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default 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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 538
Default 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!
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default 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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Variable file names Paul Peterson - Velox Consulting, LLC Excel Discussion (Misc queries) 8 February 4th 10 01:54 PM
Variable Names in Formulas Paulo Excel Discussion (Misc queries) 2 March 29th 06 01:16 PM
Using variable names in formula Karen M. Excel Programming 1 July 29th 04 01:07 AM
Variable names in SQL Hall Excel Programming 2 May 28th 04 11:39 PM
Combining variable names Bernie Gaile Excel Programming 2 December 28th 03 09:24 PM


All times are GMT +1. The time now is 08:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"