473,695 Members | 2,073 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5369
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.7976931348623 1E308 to
-4.9406564584124 7E-324; 4.9406564584124 7E-324 to 1.7976931348623 2E308
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.0000000000000 000000000000001
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*********@Se eSig.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(B yRef 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(sCurrentC har$) 'statement
Else
Mid(sInput$, i%, 1) = UCase(sCurrentC har$)
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.co m> 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.InvoiceAmoun t < 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*********@Se eSig.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(B yRef 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(sCurrentC har$) 'statement
Else
Mid(sInput$, i%, 1) = UCase(sCurrentC har$)
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*********@Se eSig.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******** *************@g 47g2000cwa.goog legroups.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
2498
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? _______________________________________________________________ http://chat.bigmir.net/ - -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: ...
2
2157
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(){} }; My questions: 1. What does it mean to have a virtual inheritenec? When do you want
4
2520
by: pete | last post by:
I found it in the view source of a corporate website. <script Language="Javascript"> <!-- var keyMacro= ]; //--> </script>
6
37793
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
2487
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 must be defined by some derived class. What does it mean when an abstract class is virtual? //Tony
10
3298
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 { return showDropDownButtons; }
9
550
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 change the & for int?
0
1843
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
1735
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. That is, the following code works. Here if T is a value type then it is always assumed to be non-null, so in the above code Compare always return true;"
1
4156
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 wanted to know the interpretation for this last line. what does it mean by :=0
0
9119
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8994
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8852
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8830
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5839
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4582
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3008
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2276
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1977
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.