473,799 Members | 3,158 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1671
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******** **********@TK2M SFTNGP10.phx.gb l... 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******** **********@TK2M SFTNGP10.phx.gb l... 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
3212
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
2121
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 understand that now and it seems to be fixed but the data I'm pulling from the HTML fields is not being appended correctly do my Access DB....The field in the DB now reads " ' ". I understand why it does that (my function) but what I need it to read is...
3
1933
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 many records. Two of the target fields in tblCorrespondence receiving values in the append operation are and . For any given VehicleJobID value, I want only ONE record in correspondence table to have an value of "01". This query blindly appends...
17
1843
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 node. To some of these entries 0a(line feed?) is being appended. I've looked through the faq and googled but haven't found much info that applies. The code follows this post(in a bit I'll split it into multiple
0
838
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 forces it to Integer.
18
2915
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
3967
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
1513
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 file ends up containing valuers from the previous runs as well... actually i am using a loop , which generates different values which are to be added to the file . can some1 help me with this i am fairly new to c++
13
3226
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 created before. My code works when I create the first class and append it to the list. However, subsequent creations and appending results in this error: "AttributeError: No __call__ method defined." Why is this so? Why does the program from the...
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10470
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
10247
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...
0
10023
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
6803
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
5459
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5583
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4135
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
3751
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.