English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Dim x, y As Integer
x = Convert.ToInt32(Me.Width / 2)
y = Convert.ToInt32(Me.Height)
e.Graphics.DrawLine(Pens.Green, x, 0, x, y)
this draws a green line but i dont understand what the ToInt32 does any one able to help?

2007-03-06 02:36:58 · 2 answers · asked by mombro 2 in Computers & Internet Programming & Design

2 answers

DrawLine() needs x and y be whole numbers, and since DrawLine() can only work to the max within a 32-bit confine it would be easier on the computer if you manage to turn x and y into integers of 32-bit range; the exact method on how VB clips off out-of-range integers are beyond me, but this is all, I think you can get away without the two ToInt32() lines but simply assign them with perhaps casting.

2007-03-06 03:14:20 · answer #1 · answered by Andy T 7 · 0 0

The 32 means 32 bits so this would produce a 32 bit integer from (Me.Width / 2) which would drop any decimal placings so 5.2 would become 5 and return at max a number with NO more than 32 bits.

If the number is larger than can be represented by 32 bits then it will have the upper bits removed (NOT entirly sure on that as I havn't use VB for a long while and don't have access to it to try out it may fail or return a different value.)

2007-03-06 10:58:55 · answer #2 · answered by Tempest 3 · 0 0

fedest.com, questions and answers