Get text "literally" from a TextBox

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

    Get text "literally" from a TextBox

    Hi, I would like make a search and replace in a file, for that I need get
    the text in a textbox, but I need recognyze literally characters of the user
    like a commands, for example:

    The chain of the user is: "Hello world" & chr(64) & vbcrlf

    If I capture the textbox, I get: ""Hello world" & chr(64) & vbcrlf"

    But I would like get the string: "Hello world@" & vbcrlf

    How make that?.

    Thanks in advance.

    Freddy Coal


  • =?Utf-8?B?U3VydHVyWg==?=

    #2
    RE: Get text "literally " from a TextBox

    You'll need to write a parser, or use a series of regexes or something like
    that.

    --
    David Streeter
    Synchrotech Software
    Sydney Australia


    "Freddy Coal" wrote:
    Hi, I would like make a search and replace in a file, for that I need get
    the text in a textbox, but I need recognyze literally characters of the user
    like a commands, for example:
    >
    The chain of the user is: "Hello world" & chr(64) & vbcrlf
    >
    If I capture the textbox, I get: ""Hello world" & chr(64) & vbcrlf"
    >
    But I would like get the string: "Hello world@" & vbcrlf
    >
    How make that?.
    >
    Thanks in advance.
    >
    Freddy Coal
    >
    >
    >

    Comment

    • Cor Ligthert[MVP]

      #3
      Re: Get text "literally " from a TextBox

      Freddy,

      Be aware that this sample goes only about char which have an integer code
      from 10 to 99 the rest you may to do yourself.

      \\\
      'assuming that you have first replaced your internal single quote by a
      double quote, I assume it goes autmaticly but I did not test that.
      Dim theString = "Hello world"" & Chr(64) & vbCrLf"
      Dim charStart = theString.Index Of("Chr")
      Dim toUseChar = Chr(CInt(theStr ing.Substring(( charStart + 4), 2)))
      Dim placeStart = theString.Index Of("""")
      theString = theString.Subst ring(0, placeStart) & toUseChar
      ///

      Cor


      "Freddy Coal" <freddycoal@gma iwithoutspam.co mschreef in bericht
      news:ehZ4frJ3IH A.5024@TK2MSFTN GP03.phx.gbl...
      Hi, I would like make a search and replace in a file, for that I need get
      the text in a textbox, but I need recognyze literally characters of the
      user like a commands, for example:
      >
      The chain of the user is: "Hello world" & chr(64) & vbcrlf
      >
      If I capture the textbox, I get: ""Hello world" & chr(64) & vbcrlf"
      >
      But I would like get the string: "Hello world@" & vbcrlf
      >
      How make that?.
      >
      Thanks in advance.
      >
      Freddy Coal
      >

      Comment

      • Patrice

        #4
        Re: Get text &quot;literally &quot; from a TextBox

        Usually advanced search/replace capabilities are using regular expressions
        rather than a VB Like syntax. See for example the search/replace included in
        VS (and it allows much more powerfull scenarios)...


        --
        Patrice


        "Freddy Coal" <freddycoal@gma iwithoutspam.co ma écrit dans le message de
        groupe de discussion : ehZ4frJ3IHA.502 4@TK2MSFTNGP03. phx.gbl...
        Hi, I would like make a search and replace in a file, for that I need get
        the text in a textbox, but I need recognyze literally characters of the
        user like a commands, for example:
        >
        The chain of the user is: "Hello world" & chr(64) & vbcrlf
        >
        If I capture the textbox, I get: ""Hello world" & chr(64) & vbcrlf"
        >
        But I would like get the string: "Hello world@" & vbcrlf
        >
        How make that?.
        >
        Thanks in advance.
        >
        Freddy Coal
        >

        Comment

        • Cor Ligthert [MVP]

          #5
          Re: Get text &quot;literally &quot; from a TextBox

          Patrice,

          Maybe you can make a little sample like I did for this problem, using string
          methods.

          Be aware that any regular expression is very much slower then any direct
          method as you don't need more than 10 methods.

          Cor

          "Patrice" <http://www.chez.com/scribe/schreef in bericht
          news:eUdwQIO3IH A.3544@TK2MSFTN GP05.phx.gbl...
          Usually advanced search/replace capabilities are using regular expressions
          rather than a VB Like syntax. See for example the search/replace included
          in VS (and it allows much more powerfull scenarios)...
          >
          >
          --
          Patrice
          >
          >
          "Freddy Coal" <freddycoal@gma iwithoutspam.co ma écrit dans le message de
          groupe de discussion : ehZ4frJ3IHA.502 4@TK2MSFTNGP03. phx.gbl...
          >Hi, I would like make a search and replace in a file, for that I need get
          >the text in a textbox, but I need recognyze literally characters of the
          >user like a commands, for example:
          >>
          >The chain of the user is: "Hello world" & chr(64) & vbcrlf
          >>
          >If I capture the textbox, I get: ""Hello world" & chr(64) & vbcrlf"
          >>
          >But I would like get the string: "Hello world@" & vbcrlf
          >>
          >How make that?.
          >>
          >Thanks in advance.
          >>
          >Freddy Coal
          >>
          >

          Comment

          • Patrice

            #6
            Re: Get text &quot;literally &quot; from a TextBox

            Be aware that any regular expression is very much slower then any direct
            method as you don't need more than 10 methods.
            Yes that's why I suggested looking at the VS IDE that allows to switch
            regular expression support on or off as needed....

            For now it looks a bit weird to me to use a VB.NET expression to enter
            characters that are easily entered using the keyboard (and you also have the
            Alt-<Num codekeys sequence or you could call charmap) so instead of using
            vb.net expressions to enter characters I would use just what the user
            entered using the keyboard and would let the user to activate regular
            expression when needed (for example to signal the end of the line if this is
            what vbCrLf is intended for in the sample).

            --
            Patrice


            Comment

            • Freddy Coal

              #7
              Re: Get text &quot;literally &quot; from a TextBox

              Cor and Patrice, thanks for the answer; I know the regular expressions, but
              my problem is how get the pattern string if the user put that in a Textbox.

              I would like get the chain the same way that when you write in Vb.Net, for
              example:

              Dim User_Pattern as string = "Hello" & chr(65) & chr(135)

              If I make that in Vb.Net, I get in the User_Pattern: "HelloAç"

              But if the user put in a Textbox: "Hello" & chr(65) & chr(135) , and I get
              that in a chain (textbox.text), I obtain:

              ""Hello" & chr(65) & chr(135)"

              Obviously, if I use that like a pattern, the regex don't replace anything,
              because he search for all the string, not for the ascii characters for 65
              (A) and 135 (ç),
              maybe I can depure my string, but exist another especial "characters " like
              vbcrlf, or when the user put strange characters with the keyboard Alt+##.

              Exits a command of make a trim "comiles" in a string variable?

              Thanks in advance.

              Freddy Coal.

              "Patrice" <http://www.chez.com/scribe/wrote in message
              news:uVROIwP3IH A.1196@TK2MSFTN GP05.phx.gbl...
              >Be aware that any regular expression is very much slower then any direct
              >method as you don't need more than 10 methods.
              >
              Yes that's why I suggested looking at the VS IDE that allows to switch
              regular expression support on or off as needed....
              >
              For now it looks a bit weird to me to use a VB.NET expression to enter
              characters that are easily entered using the keyboard (and you also have
              the Alt-<Num codekeys sequence or you could call charmap) so instead of
              using vb.net expressions to enter characters I would use just what the
              user entered using the keyboard and would let the user to activate regular
              expression when needed (for example to signal the end of the line if this
              is what vbCrLf is intended for in the sample).
              >
              --
              Patrice
              >

              Comment

              • Christiano

                #8
                Re: Get text &quot;literally &quot; from a TextBox

                why don't you write a function that will read the input and replace...

                p.e.,
                - count how many times the chr string occurs.
                - for each time, make a mid starting at i and finishing at i+4, where i
                is the indexof("chr"), store it in a variable
                - in this variable, make another mid, retrieving then code number, and
                then eval the chr...
                - replace the variable where the chr(code) was stored by the real chr
                eval...


                i lnow you will be restricted to chr codes... but you still can make a
                select for chr, asc, vbcr, vblf, vbcrlf.

                the strange chacacters will be, already, parse as string...
                if you want to remove them, use the ASCII table
                (www.computerhope.com/jargon/a/ascii.htm) and read letter by letter,
                checking if the asc( ) code is in the range of numbers and letters...



                the easiest way to do things, is the one that works...



                "Freddy Coal" <freddycoal@gma iwithoutspam.co mescreveu na mensagem
                news:%23RTKJlR3 IHA.2060@TK2MSF TNGP02.phx.gbl. ..
                Cor and Patrice, thanks for the answer; I know the regular expressions,
                but my problem is how get the pattern string if the user put that in a
                Textbox.
                >
                I would like get the chain the same way that when you write in Vb.Net, for
                example:
                >
                Dim User_Pattern as string = "Hello" & chr(65) & chr(135)
                >
                If I make that in Vb.Net, I get in the User_Pattern: "HelloAç"
                >
                But if the user put in a Textbox: "Hello" & chr(65) & chr(135) , and I
                get that in a chain (textbox.text), I obtain:
                >
                ""Hello" & chr(65) & chr(135)"
                >
                Obviously, if I use that like a pattern, the regex don't replace anything,
                because he search for all the string, not for the ascii characters for 65
                (A) and 135 (ç),
                maybe I can depure my string, but exist another especial "characters " like
                vbcrlf, or when the user put strange characters with the keyboard Alt+##.
                >
                Exits a command of make a trim "comiles" in a string variable?
                >
                Thanks in advance.
                >
                Freddy Coal.
                >
                "Patrice" <http://www.chez.com/scribe/wrote in message
                news:uVROIwP3IH A.1196@TK2MSFTN GP05.phx.gbl...
                >>Be aware that any regular expression is very much slower then any direct
                >>method as you don't need more than 10 methods.
                >>
                >Yes that's why I suggested looking at the VS IDE that allows to switch
                >regular expression support on or off as needed....
                >>
                >For now it looks a bit weird to me to use a VB.NET expression to enter
                >characters that are easily entered using the keyboard (and you also have
                >the Alt-<Num codekeys sequence or you could call charmap) so instead of
                >using vb.net expressions to enter characters I would use just what the
                >user entered using the keyboard and would let the user to activate
                >regular expression when needed (for example to signal the end of the line
                >if this is what vbCrLf is intended for in the sample).
                >>
                >--
                >Patrice
                >>
                >
                >

                Comment

                • Patrice

                  #9
                  Re: Get text &quot;literally &quot; from a TextBox

                  >
                  But if the user put in a Textbox: "Hello" & chr(65) & chr(135) , and I
                  get that in a chain (textbox.text), I obtain:
                  >
                  ""Hello" & chr(65) & chr(135)"
                  >
                  So you need to "compile" the user input... What is the level of flexibility
                  you want ?

                  You could :
                  - as suggested by others do your own parsing

                  If you need to handle "real" code you could use :
                  - http://support.microsoft.com/kb/304654/en-us (compile to an assembly
                  rather than to an exe file) and load/call the assembly. It is likely quite
                  costly.

                  Another option would be to take advantage of the J# namespace (but then you
                  would have of course to use j# syntax) :
                  -


                  I'm not sure why you need to express those chars this way but it looks very
                  unnatural to me. I would be really surprised to enter "Hello" & Chr(32) in a
                  search replace box and have all my "Hello World" strings altered as well ??
                  I'm not sure to catch the benefit you are expecting by expressing literals
                  using a VB.NET expression. For now it looks rather dangerous to me...

                  --
                  Patrice





                  Comment

                  Working...