Results 1 to 9 of 9

Thread: Upgrade problems

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2005
    Location
    Madison, WI
    Posts
    136

    Upgrade problems

    I upgraded a project from VB6 to .Net, but it leaves me with this code that has errors.
    VB Code:
    1. Dim rectype As New VB6.FixedLengthString(1)
    2.         Dim trancode As New VB6.FixedLengthString(2)
    3.         Dim recbank As New VB6.FixedLengthString(9)
    4.         Dim recbank2 As String
    5.         Dim recbank3 As String
    6.         Dim recbank4 As String
    7.         Dim bankacct As New VB6.FixedLengthString(17)
    8.         Dim amount As New VB6.FixedLengthString(10)
    9.         Dim idnumber As New VB6.FixedLengthString(15)
    10.         Dim indname As New VB6.FixedLengthString(22)
    11.         Dim discretion As New VB6.FixedLengthString(2)
    12.         Dim addenda As New VB6.FixedLengthString(1)
    13.         Dim tracenumber As New VB6.FixedLengthString(15)
    14.         Dim zst As New VB6.FixedLengthString(15)
    15.         Dim counter As Short
    16.         Dim fullrec As New VB6.FixedLengthString(94)
    17.         Dim achtotal As Integer
    18.         Dim rec1p1 As New VB6.FixedLengthString(23)
    19.         Dim rec1p2 As New VB6.FixedLengthString(10)
    20.         Dim rec1p4 As New VB6.FixedLengthString(61)
    21.         Dim fullrec1 As New VB6.FixedLengthString(94)
    22.         Dim rec5p1 As New VB6.FixedLengthString(63)
    23.         Dim rec5p2 As New VB6.FixedLengthString(6)
    24.         Dim rec5p3 As New VB6.FixedLengthString(6)
    25.         Dim rec5p4 As New VB6.FixedLengthString(19)
    26.         Dim fullrec5 As New VB6.FixedLengthString(94)
    27.         Dim rec8p1 As New VB6.FixedLengthString(4)
    28.         Dim rec8p2 As New VB6.FixedLengthString(6)
    29.         Dim rec8p3 As New VB6.FixedLengthString(10)
    30.         Dim rec8p4 As New VB6.FixedLengthString(12)
    31.         Dim rec8p5 As New VB6.FixedLengthString(12)
    32.         Dim rec8p6 As New VB6.FixedLengthString(50)
    33.         Dim fullrec8 As New VB6.FixedLengthString(94)
    34.         Dim rec9p1 As New VB6.FixedLengthString(7)
    35.         Dim rec9p2 As New VB6.FixedLengthString(6)
    36.         Dim rec9p3 As New VB6.FixedLengthString(8)
    37.         Dim rec9p4 As New VB6.FixedLengthString(10)
    38.         Dim rec9p5 As New VB6.FixedLengthString(12)
    39.         Dim rec9p6 As New VB6.FixedLengthString(12)
    40.         Dim rec9p7 As New VB6.FixedLengthString(39)
    41.         Dim fullrec9 As New VB6.FixedLengthString(94)
    42.         Dim hashcount As Integer
    43.         Dim blocks As Integer
    44.         Dim blockfill As Short
    45.         Dim fillblock As Short
    46.         Dim fullfill As New VB6.FixedLengthString(94)
    47.         Dim fillstring As New VB6.FixedLengthString(10)
    48.         Dim fillstring2 As New VB6.FixedLengthString(4)
    49.         Dim fullfill3 As New VB6.FixedLengthString(94)
    50.         Dim totalblocks As Integer
    51.         fillstring.Value = "9999999999"
    52.         fillstring2.Value = "9999"
    How would you write this in .Net friendly code? I noticed a lot of the errors stem from having "VB." in front of the statement.
    Thanks
    Last edited by callydata; Sep 13th, 2005 at 11:20 AM. Reason: adding more code

  2. #2
    Lively Member Neoharuo's Avatar
    Join Date
    Aug 2005
    Posts
    100

    Re: Upgrade problems

    Well, "VB6." isn't recognized in my version of .NET and neither is "FixedLengthString()"

    Are you including a library?
    "I aim to misbehave."
    Captain Mal Reynolds

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2005
    Location
    Madison, WI
    Posts
    136

    Re: Upgrade problems

    I am naive, I think there is a library included, I didn't post all the code, cause its long. Basically, what I need the
    VB Code:
    1. VB6.FixedLengthString(17)
    to do is specify how long the string is going to be and can only be the amount long.
    thanks

  4. #4
    Frenzied Member Asgorath's Avatar
    Join Date
    Sep 2004
    Location
    Saturn
    Posts
    2,036

    Re: Upgrade problems

    Maybe you need to add the Microsoft.VisualBasic.Compatibility.VB6 namespace.

    Regards
    Jorge
    "The dark side clouds everything. Impossible to see the future is."

  5. #5
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: Upgrade problems

    VB Code:
    1. <VBFixedString(15)> Dim FirstName As String

    From MSDN.....

    The VBFixedStringAttribute is informational and cannot be used to convert a variable length string to a fixed string. The purpose of this attribute is to modify how strings in structures and non-local variables are used by methods or API calls that recognize the VBFixedStringAttribute. Keep in mind that this attribute does not change the actual length of the string itself.

  6. #6
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: Upgrade problems

    Asgorath was correct.. go to "Project" then "add reference"... locate the "Microsoft VisualBasic .NET Compatibility Runtime" and add it.. then add the imports statement to the top of your form...

    VB Code:
    1. Imports Microsoft.VisualBasic.Compatibility

    All should be well after that...

  7. #7
    Lively Member Neoharuo's Avatar
    Join Date
    Aug 2005
    Posts
    100

    Re: Upgrade problems

    Quote Originally Posted by Asgorath
    Maybe you need to add the Microsoft.VisualBasic.Compatibility.VB6 namespace.

    Regards
    Jorge
    I'm curious, is this an added refrence or is it an Import? I can't find it in either place. Where is it?

    --Sorry, must have been posting at the same time!--
    "I aim to misbehave."
    Captain Mal Reynolds

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Sep 2005
    Location
    Madison, WI
    Posts
    136

    Re: Upgrade problems

    The add reference fixed the problem, but I am still having a problem with this code. It says the VB is not declared, I am confused about how to fix this problem as well.
    VB Code:
    1. rec8p3.Value = [COLOR=DarkRed]VB[/COLOR].Left(zst.Value, 10 - Len(Trim(Str(hashcount)))) & [COLOR=DarkRed]VB[/COLOR].Right(Str(hashcount), Len(Trim(Str(hashcount))))
    Thanks

  9. #9
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: Upgrade problems

    hehe its much longer now....

    VB Code:
    1. Microsoft.VisualBasic.Strings.Left(......)
    2. Microsoft.VisualBasic.Strings.Right(......)
    -That is unless you put in "Imports Microsoft.Visualbasic.Strings" at the top...
    then its just merely typing in "Left(....) and Right(....)

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