dcsimg
Results 1 to 2 of 2

Thread: [RESOLVED] Microsoft.VisualBasic.Powerpack

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2011
    Posts
    669

    Resolved [RESOLVED] Microsoft.VisualBasic.Powerpack

    Hi

    I have below line & i have installed Microsoft.Visualbasic.Powerpack.dll but still it is giving error - Vb6 is not declared . It may be due to protection level.

    Grid.Width = VB6.TwipsToPixelsX(VB6.PixelsToTwipsX(Ce.Width) - VB6.PixelsToTwipsX(Grid.Left))


    Thanks

  2. #2
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    5,343

    Re: Microsoft.VisualBasic.Powerpack

    It doesn't exist in VB.Net. You posted about this at least twice before. You should follow the advice given in your other thread there.
    http://www.vbforums.com/showthread.php?877493-Grid

    But I will reiterate, or address this particular question again here.

    You have two languages, VB6 and VB.Net. They both have their roots in some version of Basic but they are not the same, and one is not directly portable to the other. To be done properly, when you port a VB6 program to VB.Net, you should change much of it to use the .Net framework. And other things, like dealing with twips should be dropped altogether. In VB6 the size and location of the Form was in Twips. In VB.Net it is in pixels.

    You don't need to convert pixels to twips in VB.Net, so you should not try to convert twips to pixels in .Net.
    What you should do is understand what the code is doing, i.e. trying to center the form on the screen, or place the form on the screen, or size the form to fit the screen in some way, and then do that in VB.Net however it needs to be done in VB.Net.

    So, for instance the line you gave:

    Grid.Width = VB6.TwipsToPixelsX(VB6.PixelsToTwipsX(Ce.Width) - VB6.PixelsToTwipsX(Grid.Left))

    You have to ask what is that line doing and why, so you can do what needs to be done in .Net to accomplish the same objective.
    Is that code that came from VB6, or is it code that was translated from VB6 by something, which now doesn't work?
    What is Ce referring to in that line of code?

    What it appears to be trying to do, just looking at it, is set Grid.Width to a value that represents the desired width of the Grid in Pixels.
    It expects Ce.Width to be defined in pixels and wants to convert it to Twips.
    It expects Grid.Left to be defined in pixels and want to convert it to Twips.
    It wants to subtract the two twip values to get the difference in Twips, and then convert that back to pixels.

    That is completely unnecessary and doesn't make sense to attempt to do. If the values are pixels to begin with and you want the value to be pixels at the end, there is no need to do any conversions at all.

    The line should just be:
    Grid.Width = Ce.Width - Grid.Left

    That line looks like it would adjust the width of Grid so that the right edge of the grid aligns with the right edge of Ce, whatever Ce is.
    Last edited by passel; Aug 8th, 2019 at 01:15 AM.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width