Upgrading issue (vb6 to vb.net), help please?

liziskandar

Member
Joined
Sep 21, 2005
Messages
19
Location
Malaysia
Programming Experience
Beginner
Hello :),
First of all, sorry if I may trouble any of you.

I wanted to use this class in vb.net, so, I upgrade this class as after searching many hours online, I cannot find any appropriate example of backing up or restoring ms access database.

I've attached the code in vb 6 and also the upgraded (using VB.NET 2003) code.

But after upgrading there are some issues that I'm unable to fix and figured out as I'm just learning vb.net.

Could anyone tell me what should be done in order to fix the issue please? I have read the msdn help but I still couldn't understand how to put the arguments & function properly.

for example,
"Get#, Put# Functions In Visual Basic 6.0, the Get# and Put# functions were used to read and write data to a file.
In Visual Basic .NET, these are upgraded to the FilePut and FileGet functions. When these functions are used to pass dynamic arrays or strings to a file opened in Random mode, a two-byte length descriptor is added, resulting in a different file length.
What to do next
  • To achieve the same results as in Visual Basic 6.0, use the optional ArrayIsDynamic argument to the FilePut and FileGet functions. (How to use the ArrayIsDynamic & where to put it?)
  • When opening a file in Random mode, use the StringIsFixedLength argument."
By the way, this coding is taken from some else from PSC. (I hope I don't break any rules or violating any copyrighted. If I did, please forgive me and please remove this topic.)

Again, a million thanks for any help in advance.
 
Last edited:
I've never written code in VB6 but I've not heard good things about the upgrade wizard from anyone who's used it. The code it produces is never nearly as good as it could be. I strongly suggest, as I've heard most who've used the upgrade wizard do, that you just rewrite the whole thing in VB.NET. Work out what you want to achieve and write the best possible VB.NET code you can to achieve that aim. It will probably take not much longer, if at all, than it would to fix the problems that the wizard flags and the code is bound to be better. That way you can get to know the .NET Framework classes as well instead of using hundreds of VB6-style VB.NET Runtime functions and quite possibly even some of the Compatibility classes that exist purely for upgraded code.
 
I beleive that you should take some of the already existing class for the purpose backup/restore DB (zip/unzip) and simple include in your project (there are many free project for this). Also, as John said upgrade wizard in the VS.NET is absolutely not good idea to upgrade vb6 code to .NET. The result is terrible ... i have tried it many times before :D
Let me know if you can't find some of the projects that i mentioned above and i'll try to help you additionaly. Btw, very often i am using my own delphi project in cases like this but as i haven't made it only by myself i can't give it to you even i wish ... :(

Regards ;)
 
liziskandar,

I agree with the other folks on upgrading using the wizard...

But, I found this cool little M$ VB6 Upgrade Assessment Tool called AssessmentWizard.exe. Can't remember where I found it but try google or msdn.

Anyway, this tool allows you to assess your code project and it show's you some cool stats on what problem areas are and how to long it will take to fix the areas that won't convert.

One, thing to remember is that VB6 is object based and vb.net is OO. So it is better to look at creating object oriented code with new classes to encapsulate the functionality you need for this application. Try to think how can I write this code so I can re-use it on other programs. I have not used the old file handling code you used in your program in some time (Get and Put). However, I have used the FSO object module in VB6 a lot and found it much more user-friendly. In .net we have System.IO namespace for file handling and I'd suggest you research this namespace and create a class module to wrap the functionality of your file i/o needs. I'm sure you will need this code later and there are lots of examples in help and on-line.

Hope this helps! :)
 
Thanks Merchand. :D

I've been learning about OO since 2004, mostly theory in class lecture. I think I need to read more and understand more. :D

I'm like a box, trying to put all extra stuff immediately and doesn't realize the box already full.:eek: Now the box is tearing.:eek:
 
Back
Top