Errors in Upgrade

Posted on 2004-11-29
Medium Priority
Last Modified: 2010-04-23
I am new to VB.net and trying to upgrade a program previously written in VB6. The problem is that in the VB6 version I was passing the form as an object which is obviously not compatible with VB.net. My question is, what would be the best way of correcting this error?

An example of the code used in VB6 is as follows:

frm.txtPDate.Text = DataRcdSet.Fields("PDATE").Value

With the object "frm" being whatever form is active, containing the textbox "txtPDate".

Thanks for the Help,

Question by:bbarnette
LVL 70

Expert Comment

by:Éric Moreau
ID: 12702519
I would say that a good design won't let classes affect controls directly. Functions should return values that are set to controls from within the form itself so there is no need to pass a reference to a form or a control. What if you want to use your method with a WebForm?

But as a workaround, why don't you pass your TextBox instead?
LVL 44

Expert Comment

ID: 12702544
for starters, trying to upgrade a VB6 application to .NET is ALMOST ALWAYS an invitation to disaster.  The upgrade wizard work 'sort of', in cases where the VB 6 app is very simple - generally of the order of Hello World.

My experience has been that the basic concepts of VB 6 and .NET are different enough to ensure that the upgrade will typically lead to far more work than would be the case if you re-engineered the app using 'proper' .NET techniques.

I am a professional developer, have used VB 6 since 1994, and .NET since 2001 (started with the first BETA release).  I  have found the the two tools are different enough in basic architecture, that the only real simialrities are in the name, and the most basic syntax.  But any attempts to apply the design concepts from VB 6 to the development of a VB.NET app is usually not going to be successful.

At the present, I am doing development in both environments (VB 6/VBA and .NET) and the above commentary comes from personal experience.

LVL 96

Expert Comment

by:Bob Learned
ID: 12704841
I would agree with Arthur's assessment.  

The problem that you are having is the paradigm shift in the form class.  Forms are not globally referenced in a project in VB.NET, so you need an instance of that form:

Dim f As frm = New frm
f.txtPDate.Text = DataRcdSet.Fields("PDATE").Value

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 12711956
That worked, by passing an object of the Class with a few other minor changes, but I have another question concerning ADO. The code I previously used in the VB6 project seems to work here but is extremely slow (10-12 seconds) in retrieving a customer list that is approximately 1700 items. Do you see any problems with the code listed below, or have any idea why the dramatic difference in speed?

  Sub GetCustList(ByRef frm As Object)
        'Retrieves all customer numbers from ARCUST database, and adds customer numbers
        'to listbox for selection by user
        Dim strSQL As String
        Dim sAddedItem As String
        Dim sCustNo As String

        'SQL to get only a list of customers
        strSQL = "Select CUSTNO from ARCUST" & sLocation & " Order by CUSTNO"

        'use "ForwardOnly" to open it as fast as possible
        CustRcdSet.Open(strSQL, cn, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockOptimistic)

        '        CustRcdSet.MoveFirst()
        While Not CustRcdSet.EOF
            sCustNo = CustRcdSet.Fields("CUSTNO").Value
            'do not dupicate the customer number in the listbox
            If sAddedItem <> sCustNo Then
                sAddedItem = CustRcdSet.Fields("CUSTNO").Value
            End If


        End While

    End Sub

Thanks again for the Help,

LVL 96

Accepted Solution

Bob Learned earned 500 total points
ID: 12712018
A couple of points:

(1) Don't use ADO classic, use ADO.NET.  A ListBox bound to a DataSet should be faster than 10-12 seconds.

(2) If you must, then use a read-only, instead of LockOptimistic.

LVL 70

Expert Comment

by:Éric Moreau
ID: 12712588
You should also use a DISTINCT clause :

     strSQL = "Select DISTINCT CUSTNO from ARCUST" & sLocation & " Order by CUSTNO"

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question