473,769 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2071
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.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" <fr********@gma iwithoutspam.co mschreef in bericht
news:eh******** ******@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
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********@gma iwithoutspam.co ma é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******** ******@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" <fr********@gma iwithoutspam.co ma é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******** ******@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

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********@gma iwithoutspam.co mescreveu na mensagem
news:%2******** ********@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:uV******** ******@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


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
1887
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'} = $this->getXML($prefix . '.xml'); } I have never seen anything like this in my 3+ years of PHP coding! When I ran this code, I get the following output:
2
2213
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, "testharness.exe.config," has some <system.diagnostics> settings (trace listeners). When my file is read only, things are fine. However, when I toggle the read-only attribute off (so I can edit it), and then run my test harness, as soon as I get to the...
5
2728
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
5836
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
4232
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 c?
2
3668
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
2960
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 and I want to get the number of lines of text, but right now, unless a user hits Enter, it always reports 1 line.
6
1979
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 example, Python recognizes that the statement obviously must continue. I've noticed, however, that the same rule does not apply when a line ends with "and," "or," or "not." Yes, it's a minor point, but shouldn't the same rule apply? Seems like it...
1
1629
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 up by the web page if there is anything in it. The problem is we want to have newlines "\n" in the javascript alert, but these are treated literally in the translation. What can I do to ensure the
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10215
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9996
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8872
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7410
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6674
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3964
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3564
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.