Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21273

[RESOLVED] Need Help Drawing a Box in a Picturebox

$
0
0
The attached picture shows a dotted-line rectangle drawn on a Picturebox. Normally, to draw the rectangle you start in the upper left corner and drag the mouse to the lower right corner.

After the rectangle is drawn I move a textbox to the starting X and Y and I make the textbox's width and height using the below code:

Code:


  '
  '
 Text1.Left = StartX
 Text1.Top = StartY
 Text1.Width = EndX - StartX
 Text1.Height = EndY - StartY
  '
  '

If the user draws the rectangle the normal way then there is no problem in putting the textbox on the picturebox however if the user draws the rectangle, let's say, starting at the upper right and dragging the mouse to the lower left or some other way other than the normal way then I cannot put the textbox on the picturebox without getting errors because the math results is negative values.

How can I use code to still put a textbox on the Picturebox regardless of how the user draws the rectangle?
Attached Images
 

Viewing all articles
Browse latest Browse all 21273

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>