Get text "literally" from a TextBox

F

Freddy Coal

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
 
C

Cor Ligthert[MVP]

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.IndexOf("Chr")
Dim toUseChar = Chr(CInt(theString.Substring((charStart + 4), 2)))
Dim placeStart = theString.IndexOf("""")
theString = theString.Substring(0, placeStart) & toUseChar
///

Cor
 
S

SurturZ

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

Cor Ligthert [MVP]

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
 
F

Freddy Coal

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.
 
C

Christiano

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 said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top