Link to home
Start Free TrialLog in
Avatar of Skale
Skale

asked on

How to keep double-quote(") if string value contains it in vb.net

Hello,

I'm getting some values from excel and some cells have values like "eedm05__6924_.pdf" and this values later assigned to another program in here if all cells has same type value i can easily add double quote to start and end of the cell value but some of them integer some of them different type.

So first it should check has it contains " after that should keep them.

Any help would be grateful.
Thanks.
Avatar of Kimputer
Kimputer

Sadly, your post is somewhat hard to read, so I'm not 100% sure what you mean.
I'll just tackle a few things, and hope it's enough to get you going.

"but some of them integer some of them different type."

That's very difficult to handle. I assume you want it all to finally all be in the String format, I hope?

dim a as Integer = 9
dim added_quotes = """" + a.tostring + """"

Open in new window


Yes, there are 4 quotes in each group you see. As two are enclosing quotes for it to be a string. The other two inside the enclosing two are there, because you need to escape one quote for it to be a real quote inside the string.

"So first it should check has it contains " after that should keep them."

If you have read the cell string, and it was "eedm05__6924_.pdf", in memory it would be the same as

dim read_cell =  """eedm05__6924_.pdf"""

dim contains_quotes as Boolean = read_cell.Contains("""")

Open in new window


As you can see, another set of 4 quotes, to check if a string contains one double quote.

If this doesn't help you at all, please provide some code you already have and explain some more about what you're trying to achieve.
Avatar of Skale

ASKER

I think my problem is different i thought because of that but my problem is COM program cannot recognize my strings and i checked documentation and found convert type of string like below;

E.g.

My string is like below;
Dim strComment As String = """ra1__Pulse-VF46-160__GH0072_112__180720.cgi"""

Output string should be like
 "\"ra1__Pulse-VF46-160__GH0072_112__180720.cgi\""
ASKER CERTIFIED SOLUTION
Avatar of ste5an
ste5an
Flag of Germany image

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