LibreOffice calc conversion formula to string - formula

How to change formula, e.g. =2+2 or =CONCATENATE("hello","world") to const string value in cell?

Just in Edit Mode press F9 and Enter.

Related

How to evaluate a string in google spreadsheet

I wonder if this is possible in google sheet:
cell A2 has string 100*2 + 50
How to get the result in another cell, such as A3 = evaluate(A2) and get 250?
I have shared public google sheet "stringEvaluate" here:
https://docs.google.com/spreadsheets/d/10NzbtJhQj4hQBnZXcmwise3bLBIAWrE0qwSus_bz7a0/edit#gid=337388679
Required
Get the mathematical result from another string cell
My attempt
=query(A2) This gives the same string, does not evaluate
try:
=INDEX(QUERY(, "select "&A2), 2)

Selecting non-alpha chars with QTextCursor

I'm trying to add syntax completion to a QTextEdit base editor and I'd like to support non-alpha characters to trigger the QCompleter popup. I'm using QTextCursor::select to get the current word but it is always filtering out non-alpha characters. Is there an option I need to use for this ?
Here's the code I use to get the text:
QTextCursor tc = textCursor();
tc.select(QTextCursor::WordUnderCursor);
QString t = tc.selectedText();
thanks
Words actually do not contain alpha characters. To select the last input character:
QTextCursor tc = textCursor();
tc.movePosition ( QTextCursor::Left, QTextCursor::KeepAnchor);
QChar lastChar = tc.selectedText().at(0);
if (!lastChar.isLetterOrNumber())
{
do something;
}
Replace the isLetterOrNumber() with whatever characters you might check for.

How to convert string to int?

How to convert string to int?I know convert.ToInt32 is used.But it fail.Error is input string is not in proper format.
String s1 = "12.00"
I love the assumption that the decimal separator always is a dot (.). You'd better use the InvariantCulture, which contains a NumberFormat that explicitly specifies the dot as a decimal separator:
Convert.ToInt32(Convert.ToDouble("12.00", CultureInfo.InvariantCulture));
To clarify: half the world uses the dot, the other half a comma. When I run this on a PC with a Dutch culture and do not specify a CultureInfo, it takes the system default (comma) and returns 1200, ignoring the dot.
While it does not directly affect your problem, it is something that can't be stressed enough.
error is because string is "12.00"
first convert string to double than in int
int a = Convert.ToInt32(Convert.ToDouble("12.00"));
or
IF you just want integer part of it than
string s= "12.00";
string[] words = s.Split('.');
int a = Convert.ToInt32(words[0]);
Also check already answered threads on SO : C# Convert String Decimal to Int
"12.00" is a decimal number, not an integer. Integers don't have fractional portions. Use Convert.ToDouble or similar to get a floating-point number, or trim off the decimal part of the string (the . and what follows) prior to calling Convert.ToInt32.
The string "12.00" is a double/decimal value. Use Double.Parse() or Double.TryParse() or Convert.ToDouble().

Formatting asp.net label when the value is sourced from a query string

Afternoon all.
A very simple one for you today from thicky Rich.
I have a label I want to display as a lovely number format i.e. {0:N0}
Now, this label text equates to a query string value.
How do I go about formatting a label's text from a query string value in one fell swoop?
I have tried this
lblTotalPurchQS.Text = String.Format("{0:N0}",Request.QueryString["totalpurchasequantity"].ToString());
but with little success.
Any ideas or pointers?
Don't use ToString on the incoming query string parameter, but convert it to an int first:
lblTotalPurchQS.Text = String.Format("{0:N0}", int.Parse(Request.QueryString["totalpurchasequantity"]));
Note:
The above is not safe code. First, the conversion may fail with a conversion exception. You should also be HTML escaping the output, in case of XSS.
This is better:
int totalPurchaseQuantity;
if(int.TryParse(Request.QueryString["totalpurchasequantity"], out totalPurchaseQuantity))
{
lblTotalPurchQS.Text = Server.HtmlEncode(String.Format("{0:N0}", totalPurchaseQuantity);
}

Flex: Converting DateField text to seconds?

Is there anything wrong with following snippet of code?
var d:Date = DateField.dateToString(myDateField.text,"DD/MM/YYYY");
testTextArea.text = d.getSeconds().toString();
Error: Implicit coercion of a value of
type String to an unrelated type Date.
Here is your problem: DateField.dateToString's first parameter is supposed to be a date. It then takes that date and returns a string using the second parameter as a format string.
It looks like you're trying to convert the string to a date (the other way around) so you can get the seconds from it and put it in the text area. The DateField control has a selectedDate parameter that will give you the date you need. Then you just run this code to put it in the text area:
testTextArea.text = myDateField.selectedDate.getSeconds().toString();

Resources