Re: Calculator

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Rodrigo,

You can use the Convert class to convert the elements in the expression
(numbers) to various numeric types, but that means parsing it apart on your
own.

Taking that string, you could create the code that I laid out for you.
The problem with that is that it is susceptable to injection attacks (if you
create a code segment and compile and run it).


--
- Nicholas Paldino [.NET/C# MVP]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx

"Rodrigo Ferreira" <rjrferreira@xxxxxxxxx> wrote in message
news:e5FwFKwgFHA.3164@xxxxxxxxxxxxxxxxxxxxxxx
>
> Ok!
>
> But in textbox the type is string! How can i pass this values to decimal
> in the same order?
>
>
> "Nicholas Paldino [.NET/C# MVP]" <mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote
> in message news:O6LZSFwgFHA.1412@xxxxxxxxxxxxxxxxxxxxxxx
>>
>> Rodrigo,
>>
>> My suggestion would be to get a third party math package. Either
>> that, or you could parse it apart yourself, but you would have to handle
>> all the precidence rules yourself (not hard, but not something you should
>> have to do).
>>
>> What you could do is create a static method dynamically, something
>> like this:
>>
>> public static double Calc()
>> {
>> return 123 + 456.456 + 456 / 453 * 45 + 4.155;
>> }
>>
>> And then invoke it. It is easy to create a dynamic type to do this.
>> However, this could cause a good amount of bloat (considering how many
>> times you have to do this).
>>
>> Hope this helps.
>>
>>
>> --
>> - Nicholas Paldino [.NET/C# MVP]
>> - mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx
>>
>> "Rodrigo Ferreira" <rjrferreira@xxxxxxxxx> wrote in message
>> news:Om4ZXAwgFHA.3936@xxxxxxxxxxxxxxxxxxxxxxx
>>>
>>> I'm developing a user control with a textbox inside. When i write
>>> something like this:
>>>
>>> 123 + 456.456 + 456 / 453 * 45 + 4.155
>>>
>>> and press ENTER, the control must have to show the result.
>>>
>>> I don't know how to start!
>>>
>>> Anyone can help me?
>>>
>>>
>>>
>>
>>
>>
>
>
>


.



Relevant Pages

  • Re: how to get both old and new value for a changed text box
    ... After you put in the "Inherits TextBox" line, ... the user control on the design screen. ... Overloads Property TextAs String ... Property EnterValue() As String ...
    (microsoft.public.dotnet.languages.vb)
  • Re: how to get both old and new value for a changed text box
    ... After you put in the "Inherits TextBox" line, ... the user control on the design screen. ... Overloads Property TextAs String ... Property EnterValue() As String ...
    (microsoft.public.dotnet.languages.vb)
  • Re: how to get both old and new value for a changed text box
    ... After you put in the "Inherits TextBox" line, ... the user control on the design screen. ... Overloads Property TextAs String ... Property EnterValue() As String ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Change the textbox value of a usercontrol from the principal page
    ... And what the impact of I make all the controls public in user control? ... > If you want a generic solution, where you need to refer to each textbox by ... > string - then I don't see any way other then to use reflection. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: ListBox question
    ... other than a String, the compiler would complain. ... Dim myArray As Variant ... Dim myLong As Long ... I tested by entering a 'plain textbox shape' ...
    (microsoft.public.word.vba.general)