Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Replace$ error
#1
well, obviously i've been away from MS/VB6 for a while, and i wanted to make a quick simple encryption program in VB, which just advanced the ASCII characters by a certain amount. However i have gotten an error.

Code:
Private Sub cmdEncrypt_Click()
Message = txtInput.Text
Dim EncryptedMsg As String
Dim checknum As Long
checknum = Rand(1, 9)
For i = 0 To 255
    EncryptedMsg = Replace$(Message, Chr(i), Chr(i + checknum))
Next i

txtOutput.Text = EncryptedMsg

End Sub

Function Rand(ByVal Low As Integer, ByVal High As Integer) As Integer
    Randomize
    Rand = ((High - Low + 1) * Rnd) + Low
End Function

i get a run-time error 5: invalid procedure call or argument, and highlights this line

Code:
EncryptedMsg = Replace$(Message, Chr(i), Chr(i + checknum))

thanks,
-Pb
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)