Parse String in Quotes as without Quotes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • vighnesh

    Parse String in Quotes as without Quotes

    Hello EveryOne

    In my project I have to parse a string in Quotes as without Quotes.I tried
    the following code but it didn't work to me.
    I again getting the string with Quotes, Can Anybody suggest me where I went
    wrong?

    Thanks in advance.

    code:
    strAssociation = "rundll32.e xe"

    If strAssociation. StartsWith("""" ) Then

    strAssociation = Trim(Mid(strAss ociation, 2))

    If strAssociation. IndexOf("""") > 0 Then

    strAssociation = Left(strAssocia tion,
    strAssociation. IndexOf("""") - 1)

    End If

    End If


  • Cor Ligthert [MVP]

    #2
    Re: Parse String in Quotes as without Quotes

    Vignesh are you sure that the quotes are there, in the debugger the string
    is showed with Quotes.

    You have to look in a messagebox or something to see if there are no quotes.

    I think that the people in the C# newsgroup are not so happy with your
    crossposting by the way, with complete typical VB code.

    Cor

    "vighnesh" <vighnesh@nanna computers.com> schreef in bericht
    news:efxVoNpeGH A.1208@TK2MSFTN GP02.phx.gbl...[color=blue]
    > Hello EveryOne
    >
    > In my project I have to parse a string in Quotes as without Quotes.I tried
    > the following code but it didn't work to me.
    > I again getting the string with Quotes, Can Anybody suggest me where I
    > went wrong?
    >
    > Thanks in advance.
    >
    > code:
    > strAssociation = "rundll32.e xe"
    >
    > If strAssociation. StartsWith("""" ) Then
    >
    > strAssociation = Trim(Mid(strAss ociation, 2))
    >
    > If strAssociation. IndexOf("""") > 0 Then
    >
    > strAssociation = Left(strAssocia tion,
    > strAssociation. IndexOf("""") - 1)
    >
    > End If
    >
    > End If
    >
    >[/color]


    Comment

    • tomb

      #3
      Re: Parse String in Quotes as without Quotes

      vighnesh wrote:
      [color=blue]
      >Hello EveryOne
      >
      >In my project I have to parse a string in Quotes as without Quotes.I tried
      >the following code but it didn't work to me.
      >I again getting the string with Quotes, Can Anybody suggest me where I went
      >wrong?
      >
      >Thanks in advance.
      >
      >code:
      >strAssociati on = "rundll32.e xe"
      >
      >If strAssociation. StartsWith("""" ) Then
      >
      > strAssociation = Trim(Mid(strAss ociation, 2))
      >
      > If strAssociation. IndexOf("""") > 0 Then
      >
      > strAssociation = Left(strAssocia tion,
      >strAssociation .IndexOf("""") - 1)
      >
      > End If
      >
      >End If
      >
      >
      >
      >[/color]
      A string constant has to be given in quotes. A string variable will
      always display its value in debug with the quotes. What is it you are
      actually trying to do with this non-quoted string?

      T

      Comment

      • John B

        #4
        Re: Parse String in Quotes as without Quotes

        vighnesh wrote:[color=blue]
        > Hello EveryOne
        >
        > In my project I have to parse a string in Quotes as without Quotes.I tried
        > the following code but it didn't work to me.
        > I again getting the string with Quotes, Can Anybody suggest me where I went
        > wrong?
        >[/color]

        strAssociate = strAssociate.Tr im(new char[]{'"'});

        Or you could replace the quotes with "" if you wanted to for the whole
        string.

        Or the quote character might just be the debugger display :)

        <...>

        JB

        Comment

        • vighnesh

          #5
          Re: Parse String in Quotes as without Quotes

          ThankYou VeryMuch

          Regards
          Vighneswar
          "John B" <jbngspam@yahoo .com> wrote in message
          news:446d1d83_1 @news.iprimus.c om.au...[color=blue]
          > vighnesh wrote:[color=green]
          >> Hello EveryOne
          >>
          >> In my project I have to parse a string in Quotes as without Quotes.I
          >> tried the following code but it didn't work to me.
          >> I again getting the string with Quotes, Can Anybody suggest me where I
          >> went wrong?
          >>[/color]
          >
          > strAssociate = strAssociate.Tr im(new char[]{'"'});
          >
          > Or you could replace the quotes with "" if you wanted to for the whole
          > string.
          >
          > Or the quote character might just be the debugger display :)
          >
          > <...>
          >
          > JB[/color]


          Comment

          Working...