Hi all,

I am currently trying to remove the zeros from a string the code I have tried is as follows but it does not seem to work propperly

Dim code

code=request("code")   'here there is a string like 0000045

' I want to remove the zeros

Dim c1
c1 = CInt(code)
Dim c2
c2 = CChar(c1)

I've thought in the example below but does not show work as expected

Any idea on how normally this is done in Visual basic 6?

Thanks!

ok, solved by

CStr(CInt(code))

Should have looked for a little bit more, sorry for the post

Hi,

You can do this by:

dim code
code = "0000045"
code = replace(code,"0","")

this will remove the 0's and output just 45 in the string.

I forgot to add that with this code if you had a string "0006550" it would remove the 0 off the end as well so dont know if that would be a problem for you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.