Mathematical operations of textbox values that comes with ex siphon: R$2.00

Asked

Viewed 31 times

0

Good morning Guys, I’m having a problem making this code in C#

I have a value in a textbox that comes automatic with the "R$" so I need to take the value that comes in this textbox and do mathematical operations with them. Could someone help me with the conversion to do the operations, thank you.

1 answer

0


Eae Neto, first you will have to work with this string (Text you take from Textinput), you will have to use the substring method to take this dollar sign, the substring method will "cut" your string into a smaller chunk. Example:

TextoTrabalhado = TextoQueVocePuxouDoTextInput.Substring(PosiçãoDoInícioDoCorte,PosiçãoDoFinalDoCorte);

Then you have to convert this already worked text to a numerical value, using the Parse method. Example:

ValorNumérico = Int32.Parse(TextoTrabalhado);
  • Value brother, it worked. Thank you very much !.

  • Put my answer right there, it helps the reputation :)

  • Brother, I have another question. As a result I have a value EX: R$3520,85 , would put the correct points type EX:R$3,520,85 ?

  • Yes, you have to do the following, you have to take the number of characters of the Text you took from the input, and make an algorithm from there, for example, if it has 6 characters (9876,54) you have to pick put the point after the 0 position (which in this case is the 9)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.