| Author |
Validating Inputs, Variables and Arrays |
frangonve
Member
Posts: 110
Location: Madrid (Spain) until I can live at the beach
Joined: 18.06.08 |
| Posted on 27-02-2010 10:39 |
|
|
Hello,
I'm writing a very simple tool to help cash line attendant to calculate the cash balance.

You can download the project here:
http://rapidshare.com/files/356657297/EuroNotesAndCoins.zip
Please can you give me a hint to enhance the tool programming and specially filtering input typing mistakes (alphabetical or special chars) and to allowing the button to reset the input fields to zero.
Currently only the two top and the botton input fields are operating.
If you have another option to upload the project and so avoiding the hassle to download from rapidshare host, please let me know.
Cheers
Francisco
Edited by frangonve on 28-02-2010 18:38 |
|
| Author |
RE: Validating Inputs |
yw
Administrator
Posts: 670
Location: ***
Joined: 23.06.05 |
| Posted on 27-02-2010 18:17 |
|
|
A new version at http://www.limnor.com/Studio/LimnorStudioSetup.msi includes a control, TextboxNumber. It works as a normal TextBox except that it has two extra properties: TargetType and ValidateCulture. TargetType specifies what kind of number is acceptable. ValidateCulture indicates what culture to be used when validating the Text. Invalid characters will be ignored.
For reseting the textbox, use a Set Property action to set Text property to 0. |
|
| Author |
RE: Validating Inputs |
frangonve
Member
Posts: 110
Location: Madrid (Spain) until I can live at the beach
Joined: 18.06.08 |
| Posted on 28-02-2010 13:20 |
|
|
Thanks for your help.
Due to the limitation of size in math expresion editor where I have to calculate the total amount as:
500*{Form1.TextBoxNumber1.Text}+
200*{Form1.TextBoxNumber2.Text}+
100*{Form1.TextBoxNumber3.Text}+
50*{Form1.TextBoxNumber4.Text}+
...
0.05*{Form1.TextBoxNumber14.Text}+
0.01*{Form1.TextBoxNumber15.Text}+
I've found 2 options (perhaps there an easier one that I ovelooked...):
1 Storing each partial result in an independent variable and then adding them to compute the total amount or creating a 2 dimensions array (2 * 15):
500,{Form1.TextBoxNumber1.Text}
200,{Form1.TextBoxNumber2.Text}
100,{Form1.TextBoxNumber1.Text}
...
0.05,{Form1.TextBoxNumber14.Text}
0.01,{Form1.TextBoxNumber15.Text}
and then calculate the Total as
for j=0 to 14
Total= Total+Array(j,0)*Array(j,1)
next
Please can you give us an example to create and populate the array and then computing the Total
Cheers
Francisco
Edited by frangonve on 28-02-2010 18:43 |
|
| Author |
RE: Validating Inputs |
frangonve
Member
Posts: 110
Location: Madrid (Spain) until I can live at the beach
Joined: 18.06.08 |
| Posted on 28-02-2010 17:37 |
|
|
Hi,
I'm playing a bit with variables and I think i've found a bug:

As you can see in the picture, I've defined the variable x|0 as a constant value (500). When running this value is not taken. But if I define x|0 as a property then the value is taken correctly as you can see in this example:
http://rapidshare.com/files/357222183/Arrays003.zip
Cheers
Francisco |
|
| Author |
RE: Validating Inputs, Variables and Arrays |
frangonve
Member
Posts: 110
Location: Madrid (Spain) until I can live at the beach
Joined: 18.06.08 |
| Posted on 02-03-2010 05:42 |
|
|
Edited by frangonve on 02-03-2010 06:02 |
|
| Author |
RE: Validating Inputs, Variables and Arrays |
yw
Administrator
Posts: 670
Location: ***
Joined: 23.06.05 |
| Posted on 02-03-2010 22:14 |
|
|
The math expression bug has been fixed.
For displaying number formatted, the number's ToString(CultureInfo) can be used. I'll do some experiments.
Copy/paste can be done by Clipboard class under System.Windows.Forms namespace, using SetText to copy, using GetText to do paste.
In your case, if the labels are changed to TextBoxes then the copy/paste are automatically available without programming.
I'll to the last two questions later... |
|
| Author |
RE: Validating Inputs, Variables and Arrays |
yw
Administrator
Posts: 670
Location: ***
Joined: 23.06.05 |
| Posted on 04-03-2010 00:51 |
|
|
A new version was uploaded at http://www.limnor.com/Studio/LimnorStudioSetup.msi.
The TextBoxNumber is enhanced by adding a new property DisplayFormat. See http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx and http://msdn.microsoft.com/en-us/library/0c899ak8(VS.71).aspx for how to use DisplayFormat. For example, if DisplayFormat is N then thousand group will be used, that is, displayed as 1,234,567.89 or 1.234.567,89 depending on the ValidateCulture. If ValidateCulture is CurrentCulture and your computer is using Spanish culture then it will display 1.234.567,89
If you use TextBoxNumber to replace the Label to show parital results and the total and you get both functionality of showing numbers in formats and copy the number to clipboard.
|
|
| Author |
RE: Validating Inputs, Variables and Arrays |
frangonve
Member
Posts: 110
Location: Madrid (Spain) until I can live at the beach
Joined: 18.06.08 |
| Posted on 04-03-2010 17:35 |
|
|
Thanks a lot for your help!!
Cheers
Francisco |
|
| Author |
RE: Validating Inputs, Variables and Arrays |
yw
Administrator
Posts: 670
Location: ***
Joined: 23.06.05 |
| Posted on 04-03-2010 20:08 |
|
|
For question of using arrow keys as tab and shift-tab, we uploaded two videos showing how to do it. See http://www.limnor.com/index.html?Doc=studio_video.html.
For improvement of turnning empty to 0 for TextBoxNumber, it is done for version at http://www.limnor.com/Studio/LimnorStudioSetup.msi. |
|
| Author |
RE: Validating Inputs, Variables and Arrays |
frangonve
Member
Posts: 110
Location: Madrid (Spain) until I can live at the beach
Joined: 18.06.08 |
| Posted on 06-03-2010 01:28 |
|
|
Hello,
Thanks a lot.
I started to assign {TAB}/+{TAB} to Down/Up keys, and I have this question:
After I setup the handler with its actions in the first TextBoxNumber, Have I to repeat the whole process with the remaining TextBoxNumbers or can I assign the same handler (or a copy) to another TextBoxNumbers? If so please let me know how.
Cheers
Francisco
Edited by frangonve on 06-03-2010 01:29 |
|
| Author |
RE: Validating Inputs, Variables and Arrays |
yw
Administrator
Posts: 670
Location: ***
Joined: 23.06.05 |
| Posted on 06-03-2010 12:01 |
|
|
Good the question.
The way object-oriented programming do it is to make such a TextBoxNumber a new class. Add the handlers or other common functionality to it. Then use this new TextBoxNumber class in the Form.
This traditional way has one problem: we must know what we want before we start developing our Forms.
|
|
| Author |
RE: Validating Inputs, Variables and Arrays |
frangonve
Member
Posts: 110
Location: Madrid (Spain) until I can live at the beach
Joined: 18.06.08 |
| Posted on 06-03-2010 13:56 |
|
|
Great... I'll create a new class following the steps in the tutorial. Right?
When you say "This traditional way has one problem:..."
Do you mean that there is another way without this problem? 
Is it possible to add new features to classes in use?
Cheers
Francisco
Edited by frangonve on 06-03-2010 13:59 |
|
| Author |
RE: Validating Inputs, Variables and Arrays |
frangonve
Member
Posts: 110
Location: Madrid (Spain) until I can live at the beach
Joined: 18.06.08 |
| Posted on 07-03-2010 01:16 |
|
|
I'm trying to create a subclass based in the TextboxNumber class, But I can't find this class in the Namespaces tree.
Please. Can you help me to find it? |
|
| Author |
RE: Validating Inputs, Variables and Arrays |
yw
Administrator
Posts: 670
Location: ***
Joined: 23.06.05 |
| Posted on 08-03-2010 11:58 |
|
|
You may click the Add button to find the FormComponents.dll. I'll ask the devs to add it to Namespaces for convinience.
When I say "the traditional way..." there is not an alternative as far as I know for all object-oriented approaches such as C++, Delphi, C#, Java, etc.
Some innovations can be done in this area. For example, generate new class based on an existing component used in a form, let the user to switch the type of an existing component used in a form. |
|
| Author |
RE: Validating Inputs, Variables and Arrays |
yw
Administrator
Posts: 670
Location: ***
Joined: 23.06.05 |
| Posted on 09-03-2010 17:23 |
|
|
|
A new update is available at http://www.limnor.com/Studio/LimnorStudioSetup.msi. |
|