How do I remove these charactors from a string?

Problem:
Ok, I've tried using Substring, Trim, TrimEnd, Remove, you name it, but I still cannot get rid of these charactors "yOya".

I am sending a number via winsock and it add's the extra charactors, I need to convert the number back into an integer, in order to do that the charactors must be removed I think.

The received string looks like this "11048yOya".

-UPDATE-
Ok, for some reason it says the length of the text is 184 charactors in length using:
str.Length

Work Around:
So what I did to get by this is simply use the "yOya" portion again to split the text using str.Split("yOya"), the first element in the array is the number I need.

If the my program requires the string to be converted into an integer value to be passed off to a function as a parameter, I use either Cint(arr(0)) or CType(arr(0), Integer)

I still can't seem to remove the charactors, but this is atleast a way to get around problem for now.



Answer this question

How do I remove these charactors from a string?

  • Hans Yadav

    Instead of working around this error like this, you might consider modifying your application. It sounds as though you are reading more bytes than were provided through the socket.  The data you are receiving at the end may not be the same every time and spliting on this as a delimiter may provide errors in your code when you deploy. Perhaps if you provided your sample code that reads from the socket I could be of further assistance.   


  • metaza

    KnightSmile

    Use this to remove your character issue

    Replace(yourstringvariable, "yOya", "newvalue")

    Basicly you will remove the funny characters and assign a new value or leave the new value blank but by just useing "" and than CTYPE to convert from string to integer.

    hope this helps

     


  • How do I remove these charactors from a string?