I am presenting the user with a field that displays the number keyboard and only want them to be able to enter numbers--no decimals. Since the field is a currency field, however, I want the number to always display with two decimal places. You've probably seen this type of an interface at an ATM.
I've looked at the NSNumberFormatter docs and general formatting using [NSString stringWithFormat], but it's not clear to me a good way to do this. I am listening on the field with a selector for UIControlEventEditingChanged events. It's in that selector I want to do the formatting. When I use [NSString stringWithFormat: #"%.2f", amount], it always places amount to the left of the decimal. I want it to always be the fraction portion until the third digit is entered, so if the user types 32, the actual amount is .32. If the user enters 173, the value is actually 1.73. If the user enters 10047, the actual value should be 100.47 etc.
Any suggestions?
Thanks.
Treat the amount they're entering as cents instead of dollars. Divide it by 100 before formatting.
Related
for my evaluation I have set a date range as an input parameter. This chosen date range should be displayed in a textbox (by using a formula field for example).
What I reached so far is, that I choose a date range and CR goes through the corresponding data.
But I can only see the first and last date on which something happenend.
Example:
Entered Date range: 01.01.2019 - 16.10.2019
First/last date with a created notification: 03.01.2019 - 14.10.2019
Displayed date range: 03.01.2019 - 14.10.2019
This could cause confusion because it looks like we evaluated a shorter date period.
Is there a method to just show the entered parameters?
Thanks in advance!
Instead of placing the parameters in a formula and displaying them as this may be causing your issue. Do the following;
Get a textbox and place it in the report header. On the right in your field explorer, expand the Parameter Fields and drag the DateFrom and DateTo in the textbox. Something like this;
Doing so will display the entered range in the parameter and not the range values actually exist for.
I've got an access database which we use to book web advertising against a forecast/inventory limit.
I have three unbound text boxes which work out three things from the continuous form it sits below:
Impressions[txtImpressions]: =IIf(IsNull(Sum([Impressions]))=True,0,Sum([Impressions]))
Forecast[txtForecast]: (Populated on form load by vba)
Remaining Availability[txtDifference]: =[txtForecast]-[txtImpressions]
I would like one more box, which shows the impressions as a percentage of the forecast, so if txtImpressions contains 200 and txtForecast contains 400, I'd like the percentage box to show '50%'
I've tried =[txtForecast]/[txtImpressions] to at least divide it, but it always give me a value of 1. I've tried
=Format([txtForecast]/[txtImpressions]), Percent))
but that doesn't help either.
Can anyone help?
Set Format property of textbox with percentage to Percent (in Form designer)
You see always "1" if Decimal Places of your text box is set to 0.
Comtrol Source property of this text box should be =[txtForecast]/[txtImpressions]
I need to produce a list of integers in a label.
On the iPhone screen there are a series of 12 buttons and a label-
(0) (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (11)
[___________]
The user is to click a button, and the buttons's id should then be displayed in a label.
If the user clicks 0,4,7,3,10
Then I want the label to display- [0,4,7,3,10]
This is similar to a calculator app, but a calculator is base10 and its numbers combine to form a string. I would like to keep each integer separate so that other calculations may be performed on the user selected order.
in my #implementation i have tried to modify my calculator app's code, but have had no progress.
Any ideas?
Sounds like you need to keep an array (or some sort of stack) of the numbers pressed, and append to the label's text every time the user hits a button. What are you having issues with?
Your buttons could fire this IBAction:
- (IBAction)addNumberToLabel:(UIButton *)sender
{
[numbers addObject:[[sender titleLabel] text]];
[label setText:[NSString stringWithFormat:#"[%#]", [numbers componentsJoinedByString:#", "]];
}
Since you want the numbers to be displayed [1, 2, 3, 4], it is necessary to change the whole text of the label every time a new number is added to numbers, an NSMutableArray you initiate in your setup code.
Create a new string StrOldValue, and get the actual value of label, in the set to label use
NSString *strOldValue= yourLabel.text;
yourLabel.text= [NSString stringWithFormat:#"%#,%#",strOldValue, strNewValue)];
Keep your things in a Mutable array.
Then call componentsJoinedByString method like
NSLog(#"%#",[pathArray componentsJoinedByString:#","]);
You can use any string in place of 'Comma' as your delimiter.
I am making simple application that will take hotel name and price of item, and I want to show the price in only number format, because it can not be in alphabatical format, so what should I do add in code so that only number will be inputted in the Price UITextField?
If you are not getting my question, you may ask anything again
I do appreciate if I will get proper way of doing this,
If you want your text field to accept only the numbers, you can set it's keyboardType property to UIKeyboardTypeNumberPad.
[yourTextField setKeyboardType:UIKeyboardTypeNumberPad];
There are different types of keyboardTypes available, which you can refer in UITextInputTraits Protocol Reference.
This could be done in the Interface Builder as well:
I want to limit the length of a textfield, so that a user can know how many characters he can input. But I find no such attributes of textfield on iPhone. Any ideas how to do this?
And how to switch from one textfield to another when it reaches its max length? (to let users type easily)
You might check out the UITextFieldDelegate protocol, specifically textField:shouldChangeCharactersInRange:replacementString:. You could check if your text field has reached it's maximum size, and if so move to the next appropriate text field by sending it becomeFirstResponder: