We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

I need help converting VB6 code to .Net

JDL129
JDL129 asked
on
Medium Priority
282 Views
Last Modified: 2013-11-26
Hi All,

Please help with converting the attached vb6 code to .net.

Thanks in advance,

Jerry
DefInt A-Z
Option Explicit
 
Global PPath$                                   'program path
 
Global CancelFlag As Boolean
Global Const CCSetup_Reclen = 99
 
'Credit Card company setup
Type CCcompanyType
    Company As String * 2
    Path As String * 30
    TID As String * 32
End Type
Global CCcompany As CCcompanyType
 
'Debit Card file structure
Type DCtype
    Company As Integer
    TID As String * 32
    Phone1 As String * 20
    Phone2 As String * 20
    'fdf 3/1/2001 added..begin
    WorkingKey As String * 16
    Processor As String * 4
    Default As String * 1
    MasterKey As String * 1
    KeyManagement As String * 1
    SerialNumber As String * 16
    Blank As String * 15
    'fdf 3/1/2001 added..end
'    Blank As String * 54
End Type
Global DC As DCtype
 
'Check Services company setup
Type CHKcompanyType
    Company As String * 2
    SiteID As String * 32
    Service As String * 2
    Blank As String * 28
End Type
Global CHKcompany As CHKcompanyType
 
'fdf 2/19/2001 added..begin
'Debit Card file structure
Type GCtype
    'Company As Integer
    Company As String * 1
    TID As String * 32
    Phone1 As String * 20
    Phone2 As String * 20
    Blank As String * 54
End Type
Global GC As GCtype
'fdf 2/19/2001 added..end
 
'general program constants
Global CR$
Global LF$
 
Global Action As String

Open in new window

Comment
Watch Question

Éric MoreauSenior .Net Consultant
CERTIFIED EXPERT
Top Expert 2016

Commented:
DefInt does not exist anymore.

Do you really have to use Fixed-Lenght strings? .Net does not really support them.
Dirk HaestProject manager
CERTIFIED EXPERT

Commented:
Perhaps it's easier to tell what you exactly want.
As far as I see it, you just can create a class (a small very easy example below)
Public Class CCcompanyType
    Public Company As String
    Public Path As String
    Public TID As String
 
End Class

Open in new window

Author

Commented:
Thank you both for the responses!!
Dhaest!!
This is a class from vb6 that is used to process information to send to credit card companies.  I am a VERY newbie in .Net but am making some headway learning a new language and need this snippet changed to run in .Net.

So you can just replace 'Type' with 'Class'?  With I tried to run the in .Net the error said that 'Type' had been replaced with 'Structure'.

Can I use the following?
Public Company As String * 2

How would you dimension the 'Global's'

Thanks Again,

Jerry



Dirk HaestProject manager
CERTIFIED EXPERT

Commented:
>> Public Company As String * 2

As explained by emoreau, .net doesn't really support it

How to declare global Variables in VB.NET and C#?
http://smartypeeps.blogspot.com/2006/06/how-to-declare-global-variables-in.html

Structures
http://www.startvbdotnet.com/oop/structure.aspx

I wouldn't recommand just trying to translate your program from vb6 into vb.net, but just reprogramme the complete application

Author

Commented:
Dhaest!!

Any ideas how to handle the * values?

Thanks,

Jerry
PS:  I am in the middle of reprogramming
Dirk HaestProject manager
CERTIFIED EXPERT
Commented:
>> Any ideas how to handle the * values?

What do you mean ? Do you mean such a declaration (Phone1 As String * 20).
As already mentioned. .NET doesn't support it

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Éric MoreauSenior .Net Consultant
CERTIFIED EXPERT
Top Expert 2016
Commented:
If you really need fixed length, you can use the VBFixedString attributes as shown in http://social.msdn.microsoft.com/Forums/en-US/vbinterop/thread/e9b0e85b-2f3a-4be0-b65d-f7c6de89d7d7/
Commented:
All,

Thanks for your help!!

Both of you had good stuff to offer so I'll split the points.

Thanks again,
Jerry
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.