What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » Need VB help(Visual Basic)

Need VB help(Visual Basic)
Author: Message:
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Need VB help(Visual Basic)
Visual basic knows 2 different divisions.
One is for integers, one is for floating points.

"/" is the floating point devision. If you use that, then all variables used in the expression are first converted to floating points, then they are devided and the result will be again a floating point.

"\" is the integer devision sign. Before the expression is calculated, all the variables will be rounded down to the nearest integer (Byte, Integer, or Long) first. The result will again be an integer (and thus rounded down also).

eg:
5% / 2% = 5! / 2! = 2.5!
5! \ 2% = 5% \ 2% = 2%
89 \ 9 = 9 (and not 10; aka it is rounded down to the nearest integer, the .5 rule doesn't apply here as fractions can't exist in integers)

"%" is the marker for an 'integer'-type, "!" for a 'single'-type (aka small floating point number)

The integer devision is extremely faster than the floating point devision.

You can find this also under the topic "Arithmetic Operators" in your VB help files.

Too know exactly what integers, singles, longs, etc are look at the "Data Type Summary" topic in the help files.

---------------

Knowing the above, doesn't completely answer the question though.

The .Left, .Right, .Width, etc. properties of a form are always expressed in Twips*. Twips are always whole numbers, so you can't have something like 654.31 twips (unlike inches or centimeters which can be fractions)... Thus when you calculate the middle of the screen by deviding by 2, the solution must always be rounded to the nearest full unit anyways. So you better use integer devision for faster calculation (unless you want to use the .5 rule).

Left = (Screen.Width - Width) / 2
could have been used also of course. In that way VB will do actually the same, but the calculation would have been taken longer because VB needed to convert all the variables to floating points first and then calculate with floating point to end with dismissing the fraction in the end anyways.

;)


* a twip is a screen-independent, absolute unit of measurement. A twip is a unit of length equal to 1/20 of a printer's point, and a printer's point is 1/72 of an inch. There are approximately 1440 twips to a logical inch or 567 twips to a logical centimeter (the length of a screen item measuring one inch or one centimeter when printed). Other means of measurement include characters (not to be confused with the term "a character"), pixels (the smallest possible unit) and himetrics (unless you do very advanced stuff in VB you would never encounter or use himetrics though).

-------------------

All this info is also available in the VB help files ;)

This post was edited on 08-22-2005 at 12:09 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
08-22-2005 11:44 AM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Need VB help(Visual Basic) - by dylan! on 08-22-2005 at 07:26 AM
RE: Need VB help(Visual Basic) - by segosa on 08-22-2005 at 07:33 AM
RE: Need VB help(Visual Basic) - by dylan! on 08-22-2005 at 07:34 AM
RE: Need VB help(Visual Basic) - by Dempsey on 08-22-2005 at 07:43 AM
RE: Need VB help(Visual Basic) - by dylan! on 08-22-2005 at 07:48 AM
RE: Need VB help(Visual Basic) - by Dempsey on 08-22-2005 at 07:50 AM
RE: Need VB help(Visual Basic) - by dylan! on 08-22-2005 at 07:55 AM
RE: Need VB help(Visual Basic) - by spokes on 08-22-2005 at 08:26 AM
RE: Need VB help(Visual Basic) - by dylan! on 08-22-2005 at 08:30 AM
RE: Need VB help(Visual Basic) - by spokes on 08-22-2005 at 08:36 AM
RE: Need VB help(Visual Basic) - by dylan! on 08-22-2005 at 08:39 AM
RE: Need VB help(Visual Basic) - by spokes on 08-22-2005 at 08:47 AM
RE: Need VB help(Visual Basic) - by dylan! on 08-22-2005 at 09:13 AM
RE: Need VB help(Visual Basic) - by spokes on 08-22-2005 at 09:22 AM
RE: Need VB help(Visual Basic) - by dylan! on 08-22-2005 at 09:24 AM
RE: Need VB help(Visual Basic) - by spokes on 08-22-2005 at 09:33 AM
RE: Need VB help(Visual Basic) - by dylan! on 08-22-2005 at 09:48 AM
RE: Need VB help(Visual Basic) - by spokes on 08-22-2005 at 10:01 AM
RE: Need VB help(Visual Basic) - by spokes on 08-22-2005 at 10:10 AM
RE: Need VB help(Visual Basic) - by CookieRevised on 08-22-2005 at 11:05 AM
RE: Need VB help(Visual Basic) - by spokes on 08-22-2005 at 11:13 AM
RE: Need VB help(Visual Basic) - by CookieRevised on 08-22-2005 at 11:44 AM
RE: Need VB help(Visual Basic) - by dylan! on 08-25-2005 at 12:49 AM
RE: Need VB help(Visual Basic) - by matty on 08-25-2005 at 01:07 AM
RE: Need VB help(Visual Basic) - by CookieRevised on 08-25-2005 at 03:49 AM
RE: Need VB help(Visual Basic) - by dylan! on 08-25-2005 at 10:50 PM
RE: Need VB help(Visual Basic) - by CookieRevised on 08-25-2005 at 11:53 PM
RE: Need VB help(Visual Basic) - by dylan! on 09-11-2005 at 08:18 AM
RE: Need VB help(Visual Basic) - by spokes on 09-11-2005 at 08:32 AM
RE: Need VB help(Visual Basic) - by dylan! on 09-11-2005 at 09:03 AM
RE: Need VB help(Visual Basic) - by segosa on 09-11-2005 at 10:12 AM
RE: Need VB help(Visual Basic) - by ShawnZ on 09-11-2005 at 10:15 AM
RE: Need VB help(Visual Basic) - by mad_onion on 09-11-2005 at 09:01 PM
RE: RE: Need VB help(Visual Basic) - by segosa on 09-12-2005 at 06:48 AM
RE: Need VB help(Visual Basic) - by prashker on 09-11-2005 at 09:38 PM
RE: Need VB help(Visual Basic) - by mad_onion on 09-12-2005 at 06:15 PM
RE: RE: Need VB help(Visual Basic) - by CookieRevised on 09-14-2005 at 03:53 AM
RE: Need VB help(Visual Basic) - by dylan! on 10-09-2005 at 05:57 AM
RE: Need VB help(Visual Basic) - by CookieRevised on 10-09-2005 at 01:14 PM
RE: Need VB help(Visual Basic) - by dylan! on 10-09-2005 at 10:36 PM
RE: Need VB help(Visual Basic) - by Ezra on 10-09-2005 at 11:17 PM
RE: Need VB help(Visual Basic) - by dylan! on 10-09-2005 at 11:24 PM
RE: Need VB help(Visual Basic) - by surfichris on 10-09-2005 at 11:50 PM
RE: Need VB help(Visual Basic) - by dylan! on 10-09-2005 at 11:53 PM
RE: Need VB help(Visual Basic) - by CookieRevised on 10-10-2005 at 12:13 AM
RE: Need VB help(Visual Basic) - by dylan! on 10-10-2005 at 07:07 PM
RE: Need VB help(Visual Basic) - by Ezra on 10-10-2005 at 07:31 PM
RE: Need VB help(Visual Basic) - by dylan! on 10-22-2005 at 05:49 AM
RE: Need VB help(Visual Basic) - by CookieRevised on 10-22-2005 at 02:05 PM
RE: Need VB help(Visual Basic) - by ShawnZ on 10-22-2005 at 02:53 PM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On