Results 1 to 11 of 11

Thread: Manipulating String (Resolved)

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2001
    Location
    Maine
    Posts
    214

    Manipulating String (Resolved)

    VB Code:
    1. Dim strRecievedMessage as String
    2. For i = 1 To Len(strMessage)
    3.     strRecievedMessage = strRecievedMessage & (Chr(Asc(Mid(strMessage, i, 1)) - 10))
    4. Next i

    This gives me runtime error '5', Invalid Procedure Call or Argument. It just moves the ASCII value down 10, what is the problem?
    Last edited by jeb2022; May 3rd, 2004 at 07:49 PM.

  2. #2
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    Hmmm...

    If the character's ASCii is below 10 it'd error, thus you'd have an invalid Call, because the argument would be invalid.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jul 2001
    Location
    Maine
    Posts
    214
    When it's below 10 should i have it loop back up to the top of the ASCII chart, and have it come down to 10 when it's about 128 or whatever?

  4. #4

  5. #5
    Fanatic Member ahara's Avatar
    Join Date
    Nov 2003
    Location
    Toronto
    Posts
    531
    can you post the values of the variables when it crashed?
    "Knowledge is gained when different people look at the same information in different ways"

    - Louis Pasteur

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jul 2001
    Location
    Maine
    Posts
    214
    strMessage = ""

    That might be the problem.

  7. #7
    Fanatic Member ahara's Avatar
    Join Date
    Nov 2003
    Location
    Toronto
    Posts
    531
    impossible...you'd never get inside the for loop
    "Knowledge is gained when different people look at the same information in different ways"

    - Louis Pasteur

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Jul 2001
    Location
    Maine
    Posts
    214
    VB Code:
    1. sckMain.GetData strMessage                              'recieves the sent data
    2. MsgBox strMessage
    3. 'Decrypts
    4. For i = 1 To Len(strMessage)
    5.     strRecievedMessage = strRecievedMessage & (Chr(Asc(Mid(strMessage, i, 1)) - 10))
    6. Next i

    The message box shows nothing, however, when I debug, and mouse over strMessage, it shows me boxes, that are probably for illegal characters.

  9. #9
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    Worst encryption ever.

    Anyway...

    Set the ASC of the char to say: x

    If x < 10 then x = 255 + x
    'do your thing with x

    Conversely:

    If x > 245 then x = x - 255
    'do your thing with x

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Jul 2001
    Location
    Maine
    Posts
    214
    What, you don't like my little ASCII encryption? I really didn't feel like doing RC4 or something nice.

    Let me try this code.

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Jul 2001
    Location
    Maine
    Posts
    214
    Okay, so, it appears as if my buddy and I were trying to connect to something else. We had the wrong IP. (we're using port 1337 for kicks, so we're gonna get someone to send something to us.)

    I guess this is resolved. Thanks DigitalError and everyone else.

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