473,385 Members | 1,740 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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
Jul 2 '08 #1
8 2043
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
Jul 3 '08 #2
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
"Freddy Coal" <fr********@gmaiwithoutspam.comschreef in bericht
news:eh**************@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
Jul 3 '08 #3
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" <fr********@gmaiwithoutspam.coma écrit dans le message de
groupe de discussion : eh**************@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
Jul 3 '08 #4
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:eU**************@TK2MSFTNGP05.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" <fr********@gmaiwithoutspam.coma écrit dans le message de
groupe de discussion : eh**************@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

Jul 3 '08 #5
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
Jul 3 '08 #6
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:uV**************@TK2MSFTNGP05.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

Jul 3 '08 #7
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" <fr********@gmaiwithoutspam.comescreveu na mensagem
news:%2****************@TK2MSFTNGP02.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:uV**************@TK2MSFTNGP05.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


Jul 3 '08 #8
>
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) :
-
http://www.dotnetjunkies.com/WebLog/...11/133688.aspx

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

Jul 3 '08 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Phil Powell | last post by:
print_r("From index.php 20: $prefix: stateXML = $stateXML<P>"); foreach (array('state', 'country') as $prefix) { print_r("From index.php 21: stateXML = $stateXML<P>"); ${$prefix . 'XML'} =...
2
by: Paul Klanderud | last post by:
I'm encountering a strange situation with a .config file for a simple windows form test harness I built to test some components normally invoked by a windows service. My config file,...
5
by: Kate | last post by:
I want to display text in columns in a textBox, but can't set the position of the tabs in the box. I've used 'vbtab' , but you can't set the column/tab number. Any ideas?? TIA Kate
24
by: Mohammd M. Hussain | last post by:
Hi, I am writing an XHTML 1.0 Strict Compatible web page. However, the validator complained about the <br> tag. I wonder whether there is another alternative for this. Thanks,
72
by: Paminu | last post by:
In math this expression: (a < b) && (b < c) would be described as: a < b < c But why is it that in C these two expressions evaluate to something different for the same values of a, b and...
2
by: Alberto | last post by:
I want write in two different lines in a multiline textBox. I'm doing this: txt.Text = @"Hellow\nBye"; but it doesn't work. How can I do it? Thank you
1
by: Shawn | last post by:
Anybody know how to use wordwrap=true and multiline = true on a textbox, but still have the textbox.lines attribute advance if the wordwrap happens? I have a large textbox that is setup like this...
6
by: Russ P. | last post by:
I've always appreciated Python's lack of requirement for a semi-colon at the end of each line. I also appreciate its rules for automatic line continuation. If a statement ends with a "+", for...
1
by: Microsoft Newsserver | last post by:
Hi Folks I cant get access to books on line at the moment but I cant get to this newsgroup, so I have a question. We are passing a string of text to a textbox from which the value is popped...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.