Hi All,

I want to ask how to remove unwanted character from string??
Can provide an example?


Dim A As String
A = "@AA@BB@CC@DD"
If i want to remove @BB what method i should use?
First i try to use instr to detect where the @BB but how to do next?
Can help me and provide an example thank you....


Thanks

Look up the functions RIGHT() LEFT() MID() and LEN().

thats easy. Use Replace function.

Dim A as string 
A = Replace("@AA@BB@CC@DD", "@BB", vbNullString)

it will return @AA@CC@DD

Hopes this solves your problem.

thats easy. Use Replace function.

Dim A as string 
A = Replace("@AA@BB@CC@DD", "@BB", vbNullString)

it will return @AA@CC@DD

Hopes this solves your problem.

Thank Jahai it help a lot
If i want to remove multiple character just like this how should i do can give example:-
Dim A As String

'' Remove multiple character
A = "@AA@BB@CC@DD@EE@FF@GG@HH@AB"

'END Result
A = "@AA@GG@HH@"
So what method should i use next

Just repeat the Replace Function.

Dim A as string, B as string 
A = "@AA@BB@CC@DD@EE@FF@GG@HH@AB"
A = Replace(A, "@BB", vbNullString)
'etc

Just repeat the Replace Function.

Dim A as string, B as string 
A = "@AA@BB@CC@DD@EE@FF@GG@HH@AB"
A = Replace(A, "@BB", vbNullString)
'etc

thanks for the information

Your welcome! :D now mark this thread as solve...

Your welcome! :D now mark this thread as solve...

I still have a few question to ask before i mark this as solve

Dim A As String

A = "@AA@BB2@CC1@DD3@EE4"

''If detected CC , DD or EE5 then replace

If i do this

A = Replace(A,"@CC",vbnullstring)
A = Replace(A,"@EE4",vbnullstring)

The result will become like this
A = "@AA@BB21@DD3"

But i want to remove @CC only & not the @CC1, what the method i should use?
I want the output like this

A = "@AA@BB2@CC1@DD3"

You can use loop then use the Mid function and Iterate through the whole string.

You can use loop then use the Mid function and Iterate through the whole string.

Can you provide me an example of the coding how to do it?
I not really understand what you mean here...
Please help me....

How about showing your effort first?

You can check out this code snippet of mine to see how I manipulate the strings.

Here

Nice Jhai. The poster needs to understand that we are not here to do THEIR homework for them. Show some effort, play with the samples given and find the solution. Do you really expect Jhai to do ALL of the coding and solution for you?

:D my given samples should work with your needs so you just need to analyze and understand it.

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.