Click here to Skip to main content
15,890,186 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Everyone Good Afternoon.
I Hope Someone Helps me with my Problem.


I have 3 Textboxes and they are:

GrandTotal.Text
VatAmount.Text
TotalAmount.Text

and 1 `NumericUpdown1.Value`

Here is the Scenario, As the system goes, there is a code that will trigger and Will put a Number value in `GrandTotal.Text` and after that, The User will press `NumericUpdown1.Value`. Every time the user press it A computation will be triggered and a Number value will be Displayed in `TotalAmount.Text` and `VatAmount.Text`


To Make it more specific it is like a computation form that will include VAT. For Example.

`Grandtotal.text = 2000`

and if I press the NumericUpDown to + 1

`VatAmount.Text` = 20 and `TotalAmount.Text` = 2020


I hope you get what I mean

and Here is my code for It:



VB
Private Sub NumericUpDown1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown1.ValueChanged
  VatAmount.Text = Val(Grandtotal.text) * NumericUpDown1.Value * 0.01
  End Sub




VB
Private Sub VatAmount_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles VatAmount.TextChanged
          TotalAmount.Text = Val(VatAmount.Text) + Val(TextBox14.Text)
      End Sub


Now I`m done Explaining it here is My Question.


How to put Commas on that Textboxes and Compute It? My Prof. asked that He wants to put commas on the numbers that will bi inputted? No need to literally put Commas. Put it Automatically when value is greater that 3 Digits


How can I put commas in Textboxes and Compute it using the NumericUpdown?

What I have tried:

I tried to Search and Code it but It cant Give what I needed
Posted
Updated 16-May-16 22:03pm
v2

1 solution

I would have a read of this Standard Numeric Format Strings[^]

It will allow you to format numbers as currency while representing them as a string to the user interface.
 
Share this answer
 
Comments
Paul Edward Pagente 17-May-16 4:05am    
Sir Im done reading it but I don`t get it. :( The numbers will be putted in textboxes. Please see my edited post. I don`t know what code to be use.:( Please help me sir :(
Simon_Whale 17-May-16 4:06am    
dim value as decimal
value = 1000

--this will display with no decimal places
textbox14.Text = value.ToString("C0")

--this will display with 2 decimal places
textbox14.Text = value.ToString("C2")
Paul Edward Pagente 17-May-16 4:14am    
Sir correct me If I`m wrong what I need sir is comma but thank you for sharing the code in decimal point. I want something like this instead of 1000 it will be 1,000 or any other numbers as long as the value is greater the 999 and compute it using the NumericUpdown
Simon_Whale 17-May-16 4:16am    
Look at the "N" format specifier in the document that I showed you.
Paul Edward Pagente 17-May-16 4:20am    
I already get it Sir here is my code

Dim value As Decimal
value = TextBox14.Text
TextBox14.Text = value.ToString("N1")

I use N1 to remove the $ Sign but its not working properly in textchanged

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900