Link to home
Start Free TrialLog in
Avatar of moellert
moellert

asked on

How to get rid of spaces in a string (seams Trim$ does not work)?

I am using the following code:

Dim value As System.Text.Encoding
value = System.Text.Encoding.Default
Dim d111 As Byte()
d111 = value.GetBytes(adminusername_enc)
Dim d22(133) As Byte
NFuseEncode(d111, d111.Length, d22)
Dim s11 As String
s11 = Trim$(value.GetString(d22))
Print(a, "Adm-Username=" & s11)

NFuseEncode is taken from a seperate .dll. No need to think about.

As you can see the variable "d22" is a 133 characters long byte. When passing this in the string "s11" the output is always "Adm-Username=xxxx                                                 " with 133 - xxxx spaces at teh end.
I thought the Trim$ or RTrim$ function would kill all spaces but thats not working.

How do I get rid of all spaces at the of "s11"?
Avatar of ZeonFlash
ZeonFlash

Try using either one of these:

s11 = value.GetString(d22).Trim

s11 = Replace(value.GetString(d22), " ", "")
Avatar of moellert

ASKER

neither works
ASKER CERTIFIED SOLUTION
Avatar of Sancler
Sancler

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That did the trick.
I was Replace (s11, Char(0),"")