Hey i am creating a graphical panel and i can only set and get the integer value. How can i set the value of double type or with decimal?
Set double type value
double val = 15.56; ObjectSetString(0, "Label", OBJPROP_TEXT, DoubleToString(val, 2));
Get double type value
string doubleStr = ObjectGetString(0, "Label", OBJPROP_TEXT, 0); double val = StringToDouble(doubleStr);
I follow this way for setting and getting double type values. Thanks.
When working with the CSpinEdit class, you need to change the m_value attribute from int to double.
Old:
int m_min_value; // minimum value int m_max_value; // maximum value int m_value; // current value int MinValue(void) const { return(m_min_value); } void MinValue(const int value); int MaxValue(void) const { return(m_max_value); } void MaxValue(const int value); int Value(void) const { return(m_value); } bool Value(int value);
New:
double m_min_value; // minimum value double m_max_value; // maximum value double m_value; // current value double MinValue(void) const { return(m_min_value); } void MinValue(const double value); double MaxValue(void) const { return(m_max_value); } void MaxValue(const double value); double Value(void) const { return(m_value); } bool Value(double value);
If you want to specify the number of digits for your value, you can add some additional lines like this, for example:
int m_digits; bool Digit(const int digits); int Digit(void) const { return(m_digits); }
Abhishek Yadav:
Hey i am creating a graphical panel and i can only set and get the integer value. How can i set the value of double type or with decimal?
Download CSpinEditDouble.mqh https://www.mql5.com/en/code/download/28029/spineditdouble.mqh
Hey i am creating a graphical panel and i can only set and get the integer value. How can i set the value of double type or with decimal?
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register