473,406 Members | 2,619 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

What does var$ mean?

I've been looking at code that handles string manipulation and I keep
seeing variable names, and function names, too, followed by a '$'.
I've also found a variable followed by a '%' symbol, but I've only
seen that once. Can someone please explain this for me? I haven't
been able to find anything about it.

thanks, --thelma

Nov 13 '05 #1
9 5356
Hi Thelma

These suffixes are type declaration characters.
The $ at the end of the name is a way of declaring the variable As String.
The % at the end of the name declares the variable As Integer.

Early versions of BASIC used special characters at the end of the variable name to declare the data type. For example, the ampersand makes this variable a Long:
Dim Quantity&

This arcane style is still supported, but is less readable. One case where type declaration characters may be useful is with literal values. It is more efficient to compare two values of the same type, so you may want to code:

If Len(strMyString) = 0& Then

Since Len() returns a Long and the zero alone would be an Integer, using the type declaration character means VBA does not have to convert the Integer into a Long to perform the comparison each time this line is executed.

VBA itself uses the type declaration character in some string functions. For example, there are two functions for choosing the beginning characters from a string: Left$() returns a String, and Left() returns a Variant. Choosing the function that returns the correct type will be slightly more efficient.
I will incur the wrath of this community and post in HTML so as to include a table showing the type declaration characters and other info about the field types:

Type
Size
Range
JET Type
Initial Value
Decl Char
Prefix

Boolean
1-bit (effectively)
True/False
Yes/No
False

bool
(f, bln)

Byte
8-bit, unsigned whole number
0 to 255
Number (Byte)
0

byte

Integer
16-bit, signed whole number
-32768 to 32767
Number (Integer)
0
%
int

Long
32-bit, signed whole number
-2,147,483,648 to 2,147,483,647
Number (Long Integer)
0
&
lng

Single
32-bit, signed floating-point
3.402823E38 to -1.401298E-45;
1.401298E-45 to 3.402823E38
Number (Single)
0
!
sng

Double
64-bit, signed floating-point number
-1.79769313486231E308 to
-4.94065645841247E-324; 4.94065645841247E-324 to 1.79769313486232E308
Number (Double)
0
#
dbl

Currency
64-bit, signed fixed-point
-922,337,203,685,477.5808 to 922,337,203,685,477.5807
Currency
0
@
cur

Decimal (subtype)
96-bit signed scalable number.
+/-79,228,162,514,264,337,593,543,950,335 to +/-0.0000000000000000000000000001
Number (Decimal)
0

dec

Date
64-bit signed floating-point
January 1 100 to
December 31 9999
Date/Time
Dec. 30 1899

date (dtm)

String
Depends on length
Variable-length: approx. 2 billion
Fixed-length: up to 64k characters
Text
""
$
str
stf

Object
Address (32-bit)
sound, Word document, text box, printer, device, etc.
OLE Object
Nothing

obj

Variant

Any of the above (except fixed-length string), Empty, Null, Error, Nothing, DataObject, User-defined type

Empty

var


--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Thelma Lubkin" <th****@alpha2.csd.uwm.edu> wrote in message news:d8**********@uwm.edu...
I've been looking at code that handles string manipulation and I keep
seeing variable names, and function names, too, followed by a '$'.
I've also found a variable followed by a '%' symbol, but I've only
seen that once. Can someone please explain this for me? I haven't
been able to find anything about it.

thanks, --thelma

Nov 13 '05 #2

"Thelma Lubkin" <th****@alpha2.csd.uwm.edu> wrote in message
news:d8**********@uwm.edu...
I've been looking at code that handles string manipulation and I keep
seeing variable names, and function names, too, followed by a '$'.
I've also found a variable followed by a '%' symbol, but I've only
seen that once. Can someone please explain this for me? I haven't
been able to find anything about it.

thanks, --thelma

(Try looking in the VBA Help File.)

Data Type Declaration Characters:

$ (String)

@ (Currency)

% (Integer)

! (Single)

# (Double)

& (Long)
Nov 13 '05 #3
Allen Browne <Al*********@SeeSig.Invalid> wrote:
: Hi Thelma

: These suffixes are type declaration characters.
: The $ at the end of the name is a way of declaring the variable As String.
: The % at the end of the name declares the variable As Integer.
<snip>

: If Len(strMyString) = 0& Then
You have given me a clear and comprehensive explanation of these
symbols, but I'm not yet completely unconfused. I find code like
the function below (from a visual basic tutorial by James Laferriere)
Since he has explicitly defined all of his variables, why does he
still refer to them w/ the end-declaration characters? ...and if
he insists that everything must be explicitly announced in every
way, then why doesn't he put the $ suffix after EveryOtherCap when he
assigns to it? ..or is it now a matter of style, and I'm just
quibbling?

thanks for all your help,
--thelma

Public Function EveryOtherCap(ByRef sInput As String) As String

Dim i As Integer, sCurrentChar As String
For i% = 1 To Len(sInput$)
sCurrentChar$ = Mid(sInput$, i%, 1) 'function
If i% Mod 2 = 0 Then
Mid(sInput$, i%, 1) = LCase(sCurrentChar$) 'statement
Else
Mid(sInput$, i%, 1) = UCase(sCurrentChar$)
End If
Next i%

EveryOtherCap = sInput$

End Function
: Allen Browne - Microsoft MVP. Perth, Western Australia.
: Tips for Access users - http://allenbrowne.com/tips.html
: Reply to group, rather than allenbrowne at mvps dot org.
Nov 13 '05 #4
GoJo4 <na**@nada.com> wrote:

: "Thelma Lubkin" <th****@alpha2.csd.uwm.edu> wrote in message
: news:d8**********@uwm.edu...
:> I've been looking at code that handles string manipulation and I keep
:> seeing variable names, and function names, too, followed by a '$'.
:> I've also found a variable followed by a '%' symbol, but I've only
:> seen that once. Can someone please explain this for me? I haven't
:> been able to find anything about it.
:>
:> thanks, --thelma
:>
: (Try looking in the VBA Help File.)

: Data Type Declaration Characters:

: $ (String)

: @ (Currency)

: % (Integer)

I did look, but since I didn't know that they were
'type declaration characters', I didn't find
this list--looking up '$' isn't very helpful.
So thanks for finding it for me.
--thelma
Nov 13 '05 #5
Thelma, I am equally confused by this author's style. It serves no useful
purpose at all to add the type declaration suffix in the code when it was
not declared with the suffix. Surely that does nothing but obfuscate the
code.

I suggest you ignore his style, and use the common approach of using the AS
in the Dim statement, and not using the type declaration suffixes.

The only time I use these suffixes personally is for literal values, e.g.:
If Me.InvoiceAmount < 0@ Then ...

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Thelma Lubkin" <th****@alpha2.csd.uwm.edu> wrote in message
news:d8**********@uwm.edu...
Allen Browne <Al*********@SeeSig.Invalid> wrote:
: Hi Thelma

: These suffixes are type declaration characters.
: The $ at the end of the name is a way of declaring the variable As
String.
: The % at the end of the name declares the variable As Integer.
<snip>

: If Len(strMyString) = 0& Then
You have given me a clear and comprehensive explanation of these
symbols, but I'm not yet completely unconfused. I find code like
the function below (from a visual basic tutorial by James Laferriere)
Since he has explicitly defined all of his variables, why does he
still refer to them w/ the end-declaration characters? ...and if
he insists that everything must be explicitly announced in every
way, then why doesn't he put the $ suffix after EveryOtherCap when he
assigns to it? ..or is it now a matter of style, and I'm just
quibbling?

thanks for all your help,
--thelma

Public Function EveryOtherCap(ByRef sInput As String) As String

Dim i As Integer, sCurrentChar As String
For i% = 1 To Len(sInput$)
sCurrentChar$ = Mid(sInput$, i%, 1) 'function
If i% Mod 2 = 0 Then
Mid(sInput$, i%, 1) = LCase(sCurrentChar$) 'statement
Else
Mid(sInput$, i%, 1) = UCase(sCurrentChar$)
End If
Next i%

EveryOtherCap = sInput$

End Function

Nov 13 '05 #6
When one asks a question how does one know if the answer is adequate?
One can try the solution; if it works reasonably quickly without error
it's likely to be adequate.

How does was one know if the answer is efficient and current? This is
much more difficult. Often someone who asks a question does not have
the experience or knowledge required to make such a judgement.

Here in CDMA it's quite common to see a questionner choose the least
satisfactory answer among several posted, thanking only its poster with
a comment like, "Worked like a charm!".

Answers here are not vetted. Regulars may or may not be inclined to
point out inadequacies in answers.

In the end, each of us is responsible for what we take from here, or
any public source. In my opinion, much more than half the code posted
here in CDMA is neither efficient nor current. CAVEAT EMPTOR.

This uncertainty is heightened because newsgroups and their posters
change over time. The beginner of 2001 may be the expert of 2005.

Recently I saw a post about ADO and schema. It was quite clever. It
came from a person who posted only a few months ago, "I don't do ADO".
I was impressed.

Nov 13 '05 #7
"Allen Browne" <Al*********@SeeSig.Invalid> wrote in
news:42**********************@per-qv1-newsreader-01.iinet.net.au:
I will incur the wrath of this community and post in HTML so as to
include a table


I include tables in posts not infrequently and have never once felt
the need to post in HTML.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #8
"ly******@yahoo.ca" <ly******@yahoo.ca> wrote in
news:11*********************@g47g2000cwa.googlegro ups.com:
In the end, each of us is responsible for what we take from here,
or any public source. In my opinion, much more than half the code
posted here in CDMA is neither efficient nor current. CAVEAT
EMPTOR.


If it's not efficient, that's a valid criticism.

But current?

That's complete lunacy.

If we went by currency, we would have retired you 10 years ago,
Lyle, since you're quite an old model.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #9
Allen Browne wrote:

.... some html

This is great. It's nicely organized and I can read and understand it
easily. We have a gazillion bytes of binaries using up bandwidth every
day; why not some html here?
Are there really people using Access without high speed connections? If
there is one, should we go just text for him/her?

Yeah, yeah I know ... it's a usenet law, request, custom whatever. But
it could be changed.

--
--
Lyle

DAO: Data Access Objects. This is actually native to Microsoft Access
(more specifically, the Jet database that is at the heart of Access).
There are a lot of applications written in VB and Access that use this
technology. Too bad! This object model can be considered clunky, slow,
and just plain outdated (believe me, I'm being nice and not saying what
I really think). It's still the fastest way to access things if you're
using a Jet (Access) database but, if you're using this technology to
access SQL Server, I would suggest putting some serious effort into
migrating away from it as soon as possible. Microsoft was calling DAO a
"legacy" model more than a year before the end of the Office 97
lifecycle. They want people to stop using it, and I have to agree with them.

Robert Vieira
Professional SQL Server 2000 Programming p. 25
(Wrox)
Nov 13 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Andrey Mishenin | last post by:
While accessing MySQl data base by means of perl the value of variable $! sometimes equals " Resource temporarily unavailable". At the mean time everything works correct. What does that mean?...
2
by: pembed2003 | last post by:
Hi all, I recently saw a piece of code that looks like: class one{public: one(){} }; class two : public virtual one{public: two(){} }; class three : virtual public one{public: three(){} }; ...
4
by: pete | last post by:
I found it in the view source of a corporate website. <script Language="Javascript"> <!-- var keyMacro= ]; //--> </script>
6
by: **Developer** | last post by:
What does this mean: External component has thrown an exception. My program crashes after it leaves a subroutine. What I see during debugging is when I press F11 at the End Sub statement
2
by: tony | last post by:
Hello!! I know what an abstract class is which mean that the one of the derived class must define the abstract methods in the abstract class. So all the abstract methods in the abstarct class...
10
by: tony | last post by:
Hello!! I have some demo programs written in C# and they have this construction "" see below. I haven't seen this before so what does it mean ? public bool ShowDropDownButtons { get {...
9
by: JoeC | last post by:
m_iWidth = (int)pBitmapInfo->bmiHeader.biWidth; m_iHeight = (int)pBitmapInfo->bmiHeader.biHeight; What does this mean? I have seen v=&var->member.thing; but what does it mean when you...
0
by: steve | last post by:
What does it mean to set a value or April fools all year long :) http://beyondsql.blogspot.com/2008/03/sql-what-does-it-mean-to-set-value.html
14
by: Tony | last post by:
Hello! It says "Another limitation that you need to be aware of is that using the operator == and != are only permitted when comparing a value of a type supplied to a generic type to null....
1
by: rasmidas | last post by:
Hi, Could anyone please let me know what does it mean by the following statement in solaris shell scripting. $PROMPT " Select an option: " read ans db_option=${ans:=0} I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.