Validate textbox charset for zeros and ones - character-encoding

I'm trying to check if the charset of textbox1 contains binary, but sadly this doesn't work. Any help appreciated...
Dim binarycheck As Boolean
If binarycheck = textbox1.Text Like "[0-1]" Then
MessageBox.Show("Already in binary form!")
end if

Try
Regex.IsMatch(inputString, "^[01]+$");

Related

Replace a string in Thymeleaf

My problem is when I use the character ', Thymeleaf converts it to '.
I need to show the apostophes instead.
My string is saved in SQL like this:
"body" : "L'' autorizzazione di EUR [[${ #numbers.formatDecimal(#strings.replace(amount,'','',''.''),1,''POINT'',2, ''COMMA'')}]] in [[${date}]] ore [[${time}]] c/o presso [[${merchant}]] รจ stata negata. [[${ #strings.replace(refuseMessage,'',/'/g)}]]"
I tried string.replace but it doesn't work. Can somebody help me please?
Are you creating HTML? Then ' is correct, and you don't need to replace it.
If you are not creating HTML, then you need to make sure your template resolver is set to an appropriate template mode, for example, TEXT:
templateResolver.setTemplateMode(TemplateMode.TEXT);

How to Remove a certain part of a string (if exists)?

I am trying to make the EA look for a certain value in a string and if that value exists in the string then remove it.
I tried doing it using the StringReplace() but i noticed it only returns the number of replacements and didnt actually returned the updated string:
string v5="- .82523";
string temp2 = v5;
temp2= StringReplace(temp2," ","");
Print(v5,temp2);
in the above code there is a white space between "-" and ".82523" and i am trying to remove that white space.
so the string is - .82523 and i am trying to get -.82523 , which function can be used for this ?
initially i thought i could do it by using the StringReplace() function , but seems like it only returns the Number of replacements that had happened and not the updated string.
Thanks in Advance
You are using the StringReplace() function incorrectly. Try the following code (from your example).
string v5="- .82523";
string temp2 = v5;
StringReplace(temp2," ","");
Print("<",v5,"> <",temp2,">");

namevaluecollection removes "+" characters from querystring

I have the followigurl localhost.dev?q=dyYJDXWoTKjj9Za6Enzg4lB+NHJsrZQehfY1dqbU1fc= and extract the query string as follows:
NameValueCollection query = HttpUtility.ParseQueryString(actionContext.Request.RequestUri.Query);
string str1 = query[0];
If i call query.ToString() it shows the correct characters query string. However, when I access the value from the NameValueCollection 'query[0]' the "+" is replaced by a empty " " i.e. dyYJDXWoTKjj9Za6Enzg4lB NHJsrZQehfY1dqbU1fc=
I've tried specifing different encoding and using the Get method from the namevaluecollection. I've also tried spliting the string, but the "+" is being removed each time. Has anyone got any ideas? Many thanks
You can't use this chars in the url variables, you need use URLEncode and URLDecode of HttpUtility class to convert this into a valid url.
I hope this help you.

How to make text roll over into another textbox? Visual Basic

So, I want to make it so that, when the user pastes something into a textbox, once it pastes the first 24 characters into that textbox, it will send the rest to a richtextbox.
I've tried splitting, joining, with no luck. I don't know what else I can do. Any ideas?
I've tried:
If TextBox1.Text > TextBox1.MaxLength Then
RichTextBox4.Text = TextBox1.Text
End If
And some other weird things that didn't work out. I would appreciate some help.
Thank you.
use Substring....
Dim input = textbox1.text
Dim substring As String = input .Substring(0, 24)
richtextbox4.text = substring
http://www.dotnetperls.com/substring-vbnet

grails and double values saving

In my Grails project I have a Domain Class with a double field as follows:
double totalAmount;
the value of this field are calculated by a sum done after selecting values in a multiple select. the function for sum values is in the controller, as follows:
def sumReceiptItems(){
params.list("receiptItemsSelected").each {i-> println("element "+i)}
def appList = params.list("receiptItemsSelected")
List<ReceiptItem> allSelectedIds = ReceiptItem.findAllByIdInList(params.receiptItemsSelected.split(',')*.toLong())
def totalAmount = allSelectedIds.amount.sum()
println("totalAmount is = "+totalAmount)
render totalAmount as Double
}
the function works well. After function calling, to update the field in GSP page, I use a javascript method as follows:
function updateTotalAmount(name, data, presentNullAsThis){
if(data !=null)
document.getElementById(name).value= data;
else
document.getElementById(name).value=presentNullAsThis;
}
The javascript works and I see the updating of the field at runtime, but the double value is shown with a dot, and not with comma to separate decimal values. Infact, after clicking by save button to save the instance of the domain class, the value is saved without separating decimals, for example:
if the value into the fiels is 10.50 it is stored as 1050
In this discussion how can save a double type correctly in grails? I've read a similar problem, but solution is not good for my issue.
Anybody can help me?
Values with decimal separator depends on the current Locale of the user. Normally you use g.formatNumber in the view to display correctly the value.
You can check this topic on how to discover the decimal separator for a Locale.
To get the user's Locale use:
Locale locale = RequestContextUtils.getLocale(request)
I have solved the problem in this way:
I've updated my Javascript as follows:
function updateTotalAmount(name, data, presentNullAsThis)
{
var data2 = data.toString().replace(/\./g, ',');
if(data2 != null) document.getElementById(name).value= data2;
else document.getElementById(name).value= presentNullAsThis;
}
I've removed "type="number"" in the gsp related field

Resources