Got quite a head-scratcher....
I'm using the VBScript function REPLACE to replace spaces in a decrypted field from a MSSQL DB with "/".
But the REPLACE function isn't "seeing" the spaces.
For example, if I run any one of the following, where the decrypted value of the field "ITF_U_ClientName_Denc" is "Johnny Carson":
REPLACE(ITF_U_Ledger.Fields("ITF_U_ClientName_Denc")," ","/")
REPLACE(ITF_U_Ledger.Fields("ITF_U_ClientName_Denc")," ","/")
REPLACE(ITF_U_Ledger.Fields("ITF_U_ClientName_Denc"),"Chr(160)","/")
REPLACE(CSTR(ITF_U_Ledger.Fields("ITF_U_ClientName_Denc"))," ","/")
REPLACE(ITF_U_Ledger.Fields("ITF_U_ClientName_Denc")," ","/",1,-1,1)
REPLACE(ITF_U_Ledger.Fields("ITF_U_ClientName_Denc")," ","/",1,-1,0)
The returned value is "Johnny Carson" (space not replaced with /)
The issue seems to be exclusively with spaces, because when I run this:
REPLACE(ITF_U_Ledger.Fields("ITF_U_ClientName_Denc"),"a","/")
I get "Johnny C/rson".
Also, the issue seems to be exclusively with spaces in the decrypted value, because when I run this:
REPLACE("Johnny Carson"," ","/")
Of course, the returned value is "Johnny/Carson".
I have checked what is being written to the source of the page and it is simply "Johnny Carson" with no encoding or special characters.
I have also tried the SPLIT function to see if it would "see" the space, but it doesn't.
Finally, thanks to a helpful comment, I tried VBS REGEX searching for \s.
Set regExp = New RegExp
regExp.IgnoreCase = True
regExp.Global = True
regExp.Pattern = "\s" 'Add here every character you don't consider as special character
strProcessed = regExp.Replace(ITF_U_Ledger.Fields("ITF_U_ClientName_Denc"), "?")
Unfortunately, strProcessed retruns "Johnny Carson" (ie. spaces not detected/removed).
If I replace regExp.Pattern = "a", strProcessed returns "Johnny C?rson".
Many thanks for your help!!
As we found, the right character code is 160, and that did the trick:
replace(..., ChrW(160), "...")
This seems to be data specific and, additionally, as an alternative you can try to get same encoding of the source script (i.e. save with Save As with Encoding), or convert received database value into a different target encoding.
enter image description here
I was trying to put a list of strings ("eggs, alfalfa sprouts, bean sprouts, cabbage, tomatoes, etc) into an array. I did this however, it put each string onto a line by itself. I essentially need to correct this so it outputs "bean sprouts" and "alfalfa sprouts" on the same line not "alfalfa" then "sprouts" on the line below it. Attached is my code as well as the output that it is giving me.
I have a collection with 50 objects.
Each object contains several things but we have at least
OrgNr, Register_Id, Name, MailDate, Subject
for each object.
Assume these have the following values
OrgNr = "2556745-8145"
Register_Id = "1001"
Name = "Thailaan Asian Market"
MailDate = "2016-05-23 13:01:20"
Subject = "LPP failure"
So when I read the first object and want to add the above five fields to the ListBox I want it to be displayed like this and as one column.
2556745-8145/1001
Thailaan Asian Market
2016-05-23 13:01:20
LPP failure
So all these five fields is like one item and should be clickable.
I have been looing everywhere but the only example I have found is this
http://www.codeproject.com/articles/2695/an-editable-multi-line-listbox-for-net.
I can't use this example because I want to be able to control when I want to add CR LF which is after each written field value
//Tony
I am trying to get words with a certain prefix when a user types into a text box. For example, let's say I want all words in a text box that begins with "#". How would I go about getting these words?
One way to do it is to use the JavaScript split() method.
Let's say you get the value of a user input into one of your variables. You can use this method to get an array of String of the words that start with the prefix you chose.
var input = "#This is what the #user typed";
var splitArray = input.split("#");
// splitArray = ["This is what the", "user typed"]
I was trying to write to a file from textbox input with date:
Here is a part of the code:
DateTime dt=System::DateTime::Now;
System::IO::StreamWriter^ history = gcnew StreamWriter("history.txt");
history->WriteLine(textBox1->Text);
history->WriteLine(dt);
history->Close();
But the output is like this: text
09/02/2015 23:26:07
But I want it to be like:
text 09/02/2015 23:26:07
And also has to append next input to next line of the file.
It's something like a log file.
you use two writeLine and so that write it in 2 Line concat them to write it in one line
history->WriteLine(textBox1->Text);
history->WriteLine(dt);
change this part to
history->write(textBox1->Text);
history->writeLine(dt);
history->WriteLine(textBox1->Text);
Using WriteLine() causes the line break of course. You'd have to use Write() instead. And fret a bit about how you get the extra space between the text and the date, never hesitate to use composite formatting in .NET:
history->WriteLine("{0} {1}", textBox1->Text, System::DateTime::Now);