CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2001
    Location
    MD USA
    Posts
    12

    lines not doing what they are told

    I'm using input boxes to gather "X1 and X2" values to draw lines.
    When I input 1 inch, for instance, as a line length. I get something like 0.9991784 as what the line believes to be it's end point. While this is not necessarily a great difference, it becomes a spoiler later, when that point is needed for making a calculation involving an angle.
    I don't have this difficulty with the "Y1 and Y2"
    points which are determined the same way.
    I've tried using various methods(Creating an integer variable which passes it's value for one) to force the line to accept the input or calculated value with no success.
    Any suggestions?
    TIA
    Timg


  2. #2
    Join Date
    Nov 2000
    Location
    Tokyo and Memphis
    Posts
    238

    Re: lines not doing what they are told

    That will happen Tim. I've been through it before. I think I got around it by formatting it to take no decimal places.

    Might you also input the value as a string and then use cint(mystring) afterwards.

    Phil


  3. #3
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: lines not doing what they are told

    Try changing the mapping mode to something like "Twips".
    A line must be a whole number of mapping units long. If you have your mapping mode set to pixels and put in one inch, you would end up with 72.1 ish pixels. Once the line is drawn it becomes 72 pixels, and converting that back to inches is .9....

    HTH,
    Duncan

    -------------------------------------------------
    Ex. Datis: Duncan Jones
    Merrion Computing Ltd
    http://www.merrioncomputing.com
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

  4. #4
    Join Date
    Feb 2001
    Location
    MD USA
    Posts
    12

    Re: lines not doing what they are told

    Ok, Now the value of .X1 and .X2 are correct but using twip for that and drawing the line at the correct place on the form and at the correct length is confusing me.
    Should I perform some calculation with twip as a factor to draw the lines where I want them?
    I believe I'm way over my head with this one.
    Thanks
    Timg



  5. #5
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: lines not doing what they are told

    There are 1440 twips in an inch.

    The number of twips in a pixel depends on your screen resolution, but the visual basic "Screen" object has a memeber that you can use to find this:

    xPixel = xTwips / Screen.TwipsperPixelX
    yPixel = yTwips / Screen.TwipsPerPixelY




    HTH,
    Duncan


    -------------------------------------------------
    Ex. Datis: Duncan Jones
    Merrion Computing Ltd
    http://www.merrioncomputing.com
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured