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(DateDiff("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(String1, n, 1)) - K)
Next
Decript = OutText
End Function
any help would be most appriacated
Thank you 7 1421
"Peter Newman" <Pe*********@discussions.microsoft.comwrote in message
news:F7**********************************@microsof t.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(DateDiff("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(String1, n, 1)) - K)
Next
Decript = OutText
End Function
any help would be most appriacated
Thank you
First you must import:
Imports Microsoft.VisualBasic.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.VisualBasic.Strings.Left(String1, 2), Chr(7))
0 Then
String1 = Mid(String1, 2)
End If
If RandCode = True Then
n = Rnd(Int(DateDiff("d", ToDate, "01/01")))
Randomize(Val(Microsoft.VisualBasic.Strings.Right( "279", 2)))
End If
For n = 1 To Len(String1)
K = Int((117 - 6 + 3) * Rnd() + 8)
OutText = OutText + Chr(Asc(Mid(String1, 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
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
On Jul 2, 4:36 pm, Kerry Moorman
<KerryMoor...@discussions.microsoft.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
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.substring(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.VisualBasic.Left(String1, 2), Chr(7)) 0 Then
String1 = Mid(String1, 2)
End If
If RandCode = True Then
n = CInt(Rnd(Int(DateDiff("d", Today, "01/01"))))
Randomize(Val(Microsoft.VisualBasic.Right("279", 2)))
End If
For n = 1 To Len(String1)
K = CInt(Int((117 - 6 + 3) * Rnd() + 8))
OutText = OutText + Chr(Asc(Mid(String1, n, 1)) - K)
Next
Decript = OutText
End Function
///
"Peter Newman" <Pe*********@discussions.microsoft.comschreef in bericht
news:F7**********************************@microsof t.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(DateDiff("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(String1, n, 1)) - K)
Next
Decript = OutText
End Function
any help would be most appriacated
Thank you
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_newsgroups" <ro********@yahoo.comschreef in bericht
news:11**********************@n60g2000hse.googlegr oups.com...
On Jul 2, 4:36 pm, Kerry Moorman
<KerryMoor...@discussions.microsoft.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
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_newsgroups" <rowe_em...@yahoo.comschreef in berichtnews:11**********************@n60g2000hse.g ooglegroups.com...
On Jul 2, 4:36 pm, Kerry Moorman
<KerryMoor...@discussions.microsoft.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
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |