473,378 Members | 1,393 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,378 software developers and data experts.

appending I and % to Integers

could someone explain the following to me :

Appending the literal type character I to a literal forces it to the Integer
data type. Appending the identifier type character % to any identifier
forces it to Integer.
Nov 21 '05 #1
4 1640
This is what they mean:

Dim val1 As Integer = 5 'Normal
Dim val2 As Integer = 5% 'With %
Dim val3 As Integer = 5I 'With I

Note that the above sample is not useful because 5 is an interger by
default. But, for example, if you want to make sure that 5 is a single then
you could use this:

Dim val4 As Single = 5.0!

Hope that helps.
Lance
Nov 21 '05 #2
This is what they mean:

Dim val1 As Integer = 5 'Normal
Dim val2 As Integer = 5% 'With %
Dim val3 As Integer = 5I 'With I

Note that the above sample is not useful because 5 is an interger by
default. But, for example, if you want to make sure that 5 is a single then
you could use this:

Dim val4 As Single = 5.0!

Hope that helps.
Lance
Nov 21 '05 #3
John,
Appending the literal type character I to a literal forces it to the
Integer
data type. If you don't give a type on a numeric literal it defaults to Integer, you
can use a type character to ensure that it is specifically that type.

For example try the following, watching "value" in the Auto Watch window:

Dim value As Object

' Integer (32-bit integer) literals
value = 1
value = 2I
value = 3%

' Short (16-bit integer) literals
value = 1S

' Long (64-bit integer) literals
value = 1L
value = 2&

' Decimal literals
value = 1D
value = 2@

' Single literals
value = 1.0F
value = 2.0!

' Double literals
value = 1.0R
value = 2.0#

I normally favor the alpha character (I, S, L, F, R, D) over the special
character (%, &, !, #, @). The special characters are a hold over from
original Basic (pre Visual Basic).

The one I find missing is Byte literals.

Appending the identifier type character % to any identifier
forces it to Integer. Allows both of the follow to work with Option Strict On. I never use the
type characters on identifiers (the second line).

Dim x As Integer
Dim y%

As you can see you can use either I or % as a suffix on a numeric literal,
however you cannot use the I suffix on an identifier, as there is no way to
determine if the suffix is a type character or part of the identifier.

Hope this helps
Jay

"John A Grandy" <johnagrandy-at-yahoo-dot-com> wrote in message
news:uP******************@TK2MSFTNGP10.phx.gbl... could someone explain the following to me :

Appending the literal type character I to a literal forces it to the
Integer
data type. Appending the identifier type character % to any identifier
forces it to Integer.

Nov 21 '05 #4
John,
Appending the literal type character I to a literal forces it to the
Integer
data type. If you don't give a type on a numeric literal it defaults to Integer, you
can use a type character to ensure that it is specifically that type.

For example try the following, watching "value" in the Auto Watch window:

Dim value As Object

' Integer (32-bit integer) literals
value = 1
value = 2I
value = 3%

' Short (16-bit integer) literals
value = 1S

' Long (64-bit integer) literals
value = 1L
value = 2&

' Decimal literals
value = 1D
value = 2@

' Single literals
value = 1.0F
value = 2.0!

' Double literals
value = 1.0R
value = 2.0#

I normally favor the alpha character (I, S, L, F, R, D) over the special
character (%, &, !, #, @). The special characters are a hold over from
original Basic (pre Visual Basic).

The one I find missing is Byte literals.

Appending the identifier type character % to any identifier
forces it to Integer. Allows both of the follow to work with Option Strict On. I never use the
type characters on identifiers (the second line).

Dim x As Integer
Dim y%

As you can see you can use either I or % as a suffix on a numeric literal,
however you cannot use the I suffix on an identifier, as there is no way to
determine if the suffix is a type character or part of the identifier.

Hope this helps
Jay

"John A Grandy" <johnagrandy-at-yahoo-dot-com> wrote in message
news:uP******************@TK2MSFTNGP10.phx.gbl... could someone explain the following to me :

Appending the literal type character I to a literal forces it to the
Integer
data type. Appending the identifier type character % to any identifier
forces it to Integer.

Nov 21 '05 #5

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

Similar topics

4
by: bucket79 | last post by:
Hi is there anyway appending to dictionary? list has this feature >>>a = >>>a.append(1) >>>print a but dictionary can't
1
by: dmiller23462 | last post by:
Hey guys.... I put an error-handling in my page and have it posted at the complete end of the code, see below(when people were putting in 's I was getting the delimiter errors). Great, I...
3
by: MLH | last post by:
I have a query, qryAppend30DayOld260ies that attempts to append records to tblCorrespondence. When run, it can result in any of the following: appending no records, appending 1 record or appending...
17
by: Grant Austin | last post by:
I have a linked list where each node holds a couple numbers a char and a const char array. I use strcpy to take an char array argument passed to my insert function to copy the string into the new...
0
by: John A Grandy | last post by:
could someone explain the following to me : Appending the literal type character I to a literal forces it to the Integer data type. Appending the identifier type character % to any identifier...
18
by: Paul Roberts | last post by:
Hiya I have a string with about 300+ characters, how can i insert a line break or another character every 50 characters for the whole string? Paul Roberts
1
by: Frank | last post by:
Hi, Let's say I have a file named myFile.xml Within that file I have blocks of data which I'd like to add at different times during the day. e.g. <LogEntry>
2
by: sarada purkait | last post by:
hii i have to write into a file from the start and then go on appending to it .. i tried using ( ios::out|ios::app) but by this the file keeps on appending every time i run the program and the...
13
by: yueying53 | last post by:
I am new to creating a list of classes. Hence I checked out this website: http://www.daniweb.com/code/snippet390.html. However, I modified the code to check if a class with a particular has been...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.