Results 1 to 19 of 19

Thread: Is this VB6 to VB.NET code ok or can it be better?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2003
    Posts
    830

    Is this VB6 to VB.NET code ok or can it be better?

    After using the Upgrade Wizard, I obviously have a lot of things to fix. I used the wizard generated messages and came up with this for one of the PaintPicture problems. Would you folks take a look and see what you think? I am sure it could be done better.


    Original VB6 code......

    frmMyMain.PaintPicture frmMyMain.imgBackground.Picture, 0, 0, frmMyMain.ScaleWidth, frmMyMain.ScaleHeight

    to VB.NET code.....

    Dim gr As Graphics

    gr.DrawImage(CType(frmMyMain, frmHorizontal).DefInstance.imgBackground.Image, 0, 0, CType(frmMyMain, frmHorizontal).DefInstance.imgBackground.Image.Width, CType(frmMyMain, frmHorizontal).DefInstance.imgBackground.Image.Height)

  2. #2
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    To me it looks like you are simply putting a picture on the form, that stretches the entire length of the form?

    VB Code:
    1. MyForm1.BackGroundImage = myimage

    You can set that remarkably easy in the VS Form Designer

  3. #3
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Another reason to not use the upgrade wizard

  4. #4
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    i have yet to find a reason TO use the upgrade wizard

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2003
    Posts
    830
    Please stay on topic guys. I already have a thread on the Upgrade Wizard. The bottom line is...I am going to use it. I have a 40,000 line VB6 project and despite all the negatives I have heard about the Upgrade Wizard, I have yet to have anyone give me any documenation or articles that confirm that it is junk. From what I have seen so far, it saves a tremendous amount of time by not have to recreate all your forms. In my case I have A LOT of forms. Yes, the code is pretty ratty, but it is a good guide to upgrading (re-writing) in VB.NET. No matter how you look at, a 40,000 line conversion is a monster job.

    Anyway, by me (us) doing this we can give some good feedback on how it progresses. All support and help is appreciated.

    Thanks!

  6. #6
    Frenzied Member
    Join Date
    Mar 2004
    Location
    Orlando, FL
    Posts
    1,618
    Ugh, do yourself a huge favor and don't do it. You're going to end up with such a flakey, band-aided mess that has very little of the advantages of .NET. It may seem like this is the quicker way, but the costs in maintenance time and poor functionality down the road are going to come back and bite you.
    Sean

    Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.

  7. #7
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Yea... I would dread working on a .Net project that had been upgraded from VB6...

  8. #8
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    see im not alone

    ANY book you pickup on moving from VB6 to .NET will tell you the same thing (which is why I told it to you) MS might not say it so loud since after all the upgrade wizard IS their program. How would you feel if you worked at MS and wrote that thing (which i am sure was no easy app) and then MS just tells everyone not to use it

    If you HAVE to update it real fast and all that, then sure, use the upgrade wizard, but in your free time, work on writing it from scratch in .NET

    Not only will the app be better, but you will learn a lot more about the language itself

  9. #9
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    Originally posted by birthjay
    Please stay on topic guys. I already have a thread on the Upgrade Wizard. The bottom line is...I am going to use it. I have a 40,000 line VB6 project and despite all the negatives I have heard about the Upgrade Wizard, I have yet to have anyone give me any documenation or articles that confirm that it is junk. From what I have seen so far, it saves a tremendous amount of time by not have to recreate all your forms. In my case I have A LOT of forms. Yes, the code is pretty ratty, but it is a good guide to upgrading (re-writing) in VB.NET. No matter how you look at, a 40,000 line conversion is a monster job.

    Anyway, by me (us) doing this we can give some good feedback on how it progresses. All support and help is appreciated.

    Thanks!
    You want difinitive proof? OK, how about this: I was at a conference a while ago, and they had the guys from Microsoft come out at talk about .NET. Now, these weren't sales people, or marketing either, these were the guys in the trenches who BUILT .NET. Even they admited that the upgrade wizard was all that it was craked up to be and was only provided as a stop gap for those who wanted it. It would only convert about 60% of the code properly, with the rest needing to be done by hand. they recommended if at all possible to stay away from it and do the upgrade yourself; it'll save you a lot of pain and you'ld get to learn VB.NET at the same time.

    TG
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  10. #10
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    Yeah, I still CAN'T get it why if you having it workign in vb want it in vb.net
    \m/\m/

  11. #11
    Fanatic Member LITHIA's Avatar
    Join Date
    Dec 2002
    Location
    UK, England
    Posts
    575
    Originally posted by PT Exorcist
    Yeah, I still CAN'T get it why if you having it workign in vb want it in vb.net
    probably wants to start writing in vb.net instead and scrap vb6
    you gotta admit vb.net has a much better interface for the development environment.

    sometimes i wish they just couldn't do a proper vb7 without the .NET change! Just give us the .NET interface and put vb6 in it

  12. #12
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Originally posted by birthjay
    Please stay on topic guys. I already have a thread on the Upgrade Wizard. The bottom line is...I am going to use it. I have a 40,000 line VB6 project and despite all the negatives I have heard about the Upgrade Wizard, I have yet to have anyone give me any documenation or articles that confirm that it is junk. From what I have seen so far, it saves a tremendous amount of time by not have to recreate all your forms. In my case I have A LOT of forms. Yes, the code is pretty ratty, but it is a good guide to upgrading (re-writing) in VB.NET. No matter how you look at, a 40,000 line conversion is a monster job.

    Anyway, by me (us) doing this we can give some good feedback on how it progresses. All support and help is appreciated.

    Thanks!
    This is the topic...no matter how you look at it, this is the topic. You are using the upgrade wizard, and you are asking for documentation about it. Well, what about ALL of our documentation that we have provided on this forum for you. Do you really think that all the "Professional" developers here are lying to you?

    You want more proof:
    Upgrade Wizard:
    Code:
    Dim gr As Graphics
    
    gr.DrawImage(CType(frmMyMain, frmHorizontal).DefInstance.imgBackground.Image, 0, 0, CType(frmMyMain, frmHorizontal).DefInstance.imgBackground.Image.Width, CType(frmMyMain, frmHorizontal).DefInstance.imgBackground.Image.Height)
    By hand (really could have been done in the property window also):
    Code:
    MyForm1.BackGroundImage = myimage

  13. #13
    Member
    Join Date
    Apr 2004
    Location
    Millbrae, CA
    Posts
    48
    Upgrade wizard is as useful as a one legged man in an ass kicking contest.

  14. #14
    Fanatic Member TTn's Avatar
    Join Date
    Jul 2004
    Posts
    708
    LITHIA, sometimes i wish they just couldn't do a proper vb7 without the .NET change! Just give us the .NET interface and put vb6 in it"

    I think they did, most code need not be changed, if you reference vb I read the phase out time for MS is about seven+ years.


    #Region "Windows Form Designer generated code "
    Public Sub New()
    MyBase.New()
    If m_vb6FormDefInstance Is Nothing Then
    If m_InitializingDefInstance Then
    m_vb6FormDefInstance = Me
    Else
    Try
    'For the start-up form, the first instance created is the default instance.
    If System.Reflection.Assembly.GetExecutingAssembly.EntryPoint.DeclaringType Is Me.GetType Then
    m_vb6FormDefInstance = Me
    End If
    Catch
    End Try
    End If
    End If
    'This call is required by the Windows Form Designer.
    InitializeComponent()
    End Sub

    #Region "Upgrade Support "
    Private Shared m_vb6FormDefInstance As frmMain
    Private Shared m_InitializingDefInstance As Boolean

  15. #15
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Originally posted by birthjay
    despite all the negatives I have heard about the Upgrade Wizard, I have yet to have anyone give me any documenation or articles that confirm that it is junk.
    Articles won't tell you **** about the upgrade wizard. They'll just tell you how to use it.

    How about more: It's department policy that we never, ever, ever, ever use the upgrade wizard. No matter if we're running short on time, they'll work with us. But no upgrade wizard!

  16. #16
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Read this thread from gotdotnet forums. Strangely, he's got 40000 lines of code too.

    Read all the comments given there, and be sure to visit this link, if you're still adamant on using the wizard:

    http://msdn.microsoft.com/vbasic/dow...r/default.aspx

  17. #17
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    You forgot the link?
    \m/\m/

  18. #18
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

  19. #19

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2003
    Posts
    830
    Thank you for all the opinions on the Upgrade Wizard.

    The point I was trying to make in requesting "to stay on topic" is that I had already heard the "opinions" about the Upgrade Wizard. I do appreciate each and every opinion that was posted though.

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