vb6 - vb.net 2005

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?UGV0ZXIgTmV3bWFu?=

    #1

    vb6 - vb.net 2005

    I have inherited this vb6 code which i am trying to rewrite using vb.net 2005
    I need to be able to get this working as we cannot issue out new end user
    software at the moment

    Public Function Decript(String1 ) As String
    Dim n, K As Integer
    Dim OutText As String

    If InStr(1, Left(String1, 2), Chr(7)) 0 Then
    String1 = Mid(String1, 2)
    End If

    If RandCode = True Then
    n = Rnd(Int(DateDif f("d", ToDate, "01/01")))
    Randomize (Val(Right("279 ", 2)))
    End If

    For n = 1 To Len(String1)
    K = Int((117 - 6 + 3) * Rnd + 8)
    OutText = OutText + Chr(Asc(Mid(Str ing1, n, 1)) - K)
    Next
    Decript = OutText

    End Function


    any help would be most appriacated
    Thank you
  • Lloyd Sheen

    #2
    Re: vb6 - vb.net 2005


    "Peter Newman" <PeterNewman@di scussions.micro soft.comwrote in message
    news:F75C4688-64B5-4414-A395-A0C4524A013B@mi crosoft.com...
    >I have inherited this vb6 code which i am trying to rewrite using vb.net
    >2005
    I need to be able to get this working as we cannot issue out new end user
    software at the moment
    >
    Public Function Decript(String1 ) As String
    Dim n, K As Integer
    Dim OutText As String
    >
    If InStr(1, Left(String1, 2), Chr(7)) 0 Then
    String1 = Mid(String1, 2)
    End If
    >
    If RandCode = True Then
    n = Rnd(Int(DateDif f("d", ToDate, "01/01")))
    Randomize (Val(Right("279 ", 2)))
    End If
    >
    For n = 1 To Len(String1)
    K = Int((117 - 6 + 3) * Rnd + 8)
    OutText = OutText + Chr(Asc(Mid(Str ing1, n, 1)) - K)
    Next
    Decript = OutText
    >
    End Function
    >
    >
    any help would be most appriacated
    Thank you

    First you must import:

    Imports Microsoft.Visua lBasic.Strings


    Then use the following code:

    Public Function Decript(ByVal String1) As String
    Dim n, K As Integer
    Dim OutText As String

    If InStr(1, Microsoft.Visua lBasic.Strings. Left(String1, 2), Chr(7))
    0 Then
    String1 = Mid(String1, 2)
    End If

    If RandCode = True Then
    n = Rnd(Int(DateDif f("d", ToDate, "01/01")))
    Randomize(Val(M icrosoft.Visual Basic.Strings.R ight("279", 2)))
    End If

    For n = 1 To Len(String1)
    K = Int((117 - 6 + 3) * Rnd() + 8)
    OutText = OutText + Chr(Asc(Mid(Str ing1, n, 1)) - K)
    Next
    Return OutText

    End Function

    I don't know what RandCode or ToDate are supposed to be but other than that
    it should work identically.

    Notice that in VB.Net you use the return verb rather than assign the value
    of the return to the function name as in VB6.

    Hope this helps.

    Lloyd Sheen

    Comment

    • =?Utf-8?B?S2VycnkgTW9vcm1hbg==?=

      #3
      Re: vb6 - vb.net 2005

      Lloyd,

      In VB.Net, both methods of returning a value from a function work identically.

      Kerry Moorman

      "Lloyd Sheen" wrote:
      >
      >
      Notice that in VB.Net you use the return verb rather than assign the value
      of the return to the function name as in VB6.
      >
      Hope this helps.
      >
      Lloyd Sheen
      >

      Comment

      • rowe_newsgroups

        #4
        Re: vb6 - vb.net 2005

        On Jul 2, 4:36 pm, Kerry Moorman
        <KerryMoor...@d iscussions.micr osoft.comwrote:
        Lloyd,
        >
        In VB.Net, both methods of returning a value from a function work identically.
        >
        Kerry Moorman
        >
        "Lloyd Sheen" wrote:
        >
        Notice that in VB.Net you use the return verb rather than assign the value
        of the return to the function name as in VB6.
        >
        Hope this helps.
        >
        Lloyd Sheen
        In VB.Net, both methods of returning a value from a function work identically.
        Yes, but return is much better when you rename a function - a feature
        I sorely missed in vb classic.

        Thanks,

        Seth Rowe

        Comment

        • Cor Ligthert [MVP]

          #5
          Re: vb6 - vb.net 2005

          Peter,

          I am absolute no VB6 guy anymore, however just with as less changes as
          possible.

          You can change the Left, Mid by substring, which is in my idea easier and
          common to use
          string1.substri ng(starting where indexer is zero, length)

          \\\
          Public Function Decript(ByVal String1 As String, ByVal RandCode As Boolean)
          As String
          Dim n, K As Integer
          Dim OutText As String

          If InStr(1, Microsoft.Visua lBasic.Left(Str ing1, 2), Chr(7)) 0 Then
          String1 = Mid(String1, 2)
          End If

          If RandCode = True Then
          n = CInt(Rnd(Int(Da teDiff("d", Today, "01/01"))))
          Randomize(Val(M icrosoft.Visual Basic.Right("27 9", 2)))
          End If

          For n = 1 To Len(String1)
          K = CInt(Int((117 - 6 + 3) * Rnd() + 8))
          OutText = OutText + Chr(Asc(Mid(Str ing1, n, 1)) - K)
          Next
          Decript = OutText

          End Function
          ///

          "Peter Newman" <PeterNewman@di scussions.micro soft.comschreef in bericht
          news:F75C4688-64B5-4414-A395-A0C4524A013B@mi crosoft.com...
          >I have inherited this vb6 code which i am trying to rewrite using vb.net
          >2005
          I need to be able to get this working as we cannot issue out new end user
          software at the moment
          >
          Public Function Decript(String1 ) As String
          Dim n, K As Integer
          Dim OutText As String
          >
          If InStr(1, Left(String1, 2), Chr(7)) 0 Then
          String1 = Mid(String1, 2)
          End If
          >
          If RandCode = True Then
          n = Rnd(Int(DateDif f("d", ToDate, "01/01")))
          Randomize (Val(Right("279 ", 2)))
          End If
          >
          For n = 1 To Len(String1)
          K = Int((117 - 6 + 3) * Rnd + 8)
          OutText = OutText + Chr(Asc(Mid(Str ing1, n, 1)) - K)
          Next
          Decript = OutText
          >
          End Function
          >
          >
          any help would be most appriacated
          Thank you

          Comment

          • Cor Ligthert [MVP]

            #6
            Re: vb6 - vb.net 2005

            Lloyd,
            Yes, but return is much better when you rename a function -
            I would not write "better", in my idea is it your personal preference, as it
            is mine too.

            :-)

            Cor

            "rowe_newsgroup s" <rowe_email@yah oo.comschreef in bericht
            news:1183416981 .454107.218940@ n60g2000hse.goo glegroups.com.. .
            On Jul 2, 4:36 pm, Kerry Moorman
            <KerryMoor...@d iscussions.micr osoft.comwrote:
            >Lloyd,
            >>
            >In VB.Net, both methods of returning a value from a function work
            >identically.
            >>
            >Kerry Moorman
            >>
            >"Lloyd Sheen" wrote:
            >>
            Notice that in VB.Net you use the return verb rather than assign the
            value
            of the return to the function name as in VB6.
            >>
            Hope this helps.
            >>
            Lloyd Sheen
            >
            >
            >In VB.Net, both methods of returning a value from a function work
            >identically.
            >
            Yes, but return is much better when you rename a function - a feature
            I sorely missed in vb classic.
            >
            Thanks,
            >
            Seth Rowe
            >

            Comment

            • rowe_newsgroups

              #7
              Re: vb6 - vb.net 2005

              On Jul 3, 1:09 am, "Cor Ligthert [MVP]" <notmyfirstn... @planet.nl>
              wrote:
              Lloyd,
              >
              Yes, but return is much better when you rename a function -
              >
              I would not write "better", in my idea is it your personal preference, as it
              is mine too.
              >
              :-)
              >
              Cor
              >
              "rowe_newsgroup s" <rowe_em...@yah oo.comschreef in berichtnews:118 3416981.454107. 218940@n60g2000 hse.googlegroup s.com...
              >
              On Jul 2, 4:36 pm, Kerry Moorman
              <KerryMoor...@d iscussions.micr osoft.comwrote:
              Lloyd,
              >
              In VB.Net, both methods of returning a value from a function work
              identically.
              >
              Kerry Moorman
              >
              "Lloyd Sheen" wrote:
              >
              Notice that in VB.Net you use the return verb rather than assign the
              value
              of the return to the function name as in VB6.
              >
              Hope this helps.
              >
              Lloyd Sheen
              >
              In VB.Net, both methods of returning a value from a function work
              identically.
              >
              Yes, but return is much better when you rename a function - a feature
              I sorely missed in vb classic.
              >
              Thanks,
              >
              Seth Rowe

              I would not write "better", in my idea is it your personal preference, as it
              is mine too.
              Oops, I guess I forgot my IMO tag in my previous statement.

              Besides, if you and I actually agree it has to be correct right?

              :-)

              Thanks,

              Seth Rowe

              Comment

              • Andrew Morton

                #8
                Re: vb6 - vb.net 2005

                Kerry Moorman wrote:
                In VB.Net, both methods of returning a value from a function work
                identically.
                Not quite - from the help:
                "Return is equivalent to assigning the expression to the function name as
                the return value and then executing an Exit Function statement"

                Andrew


                Comment

                Working...