954,551 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How do I mutiply and add with textboxes?

I am making a invoice program and I tried multiplying the number of times clicked which is in a text box and the price of the item which is is my resources. I already have the code to count how many times the button is clicked. Please Help!!


Thank you so much in advance!!

Attachments Help_with_visual_basic.png 72.9KB
kanyonb38
Newbie Poster
9 posts since Nov 2011
Reputation Points: 10
Solved Threads: 0
 

If you already have the code the in which part you are struck with ?

debasisdas
Posting Genius
6,872 posts since Feb 2007
Reputation Points: 666
Solved Threads: 434
 

I am making a invoice program and I tried multiplying the number of times clicked which is in a text box and the price of the item which is is my resources. I already have the code to count how many times the button is clicked. Please Help!!

Thank you so much in advance!!

I need to multiply the number of times the button was clicked by the price which is in my resources.

kanyonb38
Newbie Poster
9 posts since Nov 2011
Reputation Points: 10
Solved Threads: 0
 

Just make sure to convert the value in your text box to a numeric datatype using a conversion function. Since you are calculating prices, you might consider the CCur conversion function. Look in the VB help file for details on how to use it.

You might have to test the value in your textbox first to make sure it is a number, using the IsNumeric function. Again, details are available in the VB help file.

Good luck!

BitBlt
Master Poster
711 posts since Feb 2011
Reputation Points: 367
Solved Threads: 109
 

I am making a invoice program and I tried multiplying the number of times clicked which is in a text box and the price of the item which is is my resources. I already have the code to count how many times the button is clicked. Please Help!!

Thank you so much in advance!!

Thanks for that it helps a lot, but I'm a newbie and don't know anything about coding so could you guide me in the right direction of what the coding should be.

The Number of times clicked is "numberofcofee"
and the price is "My.Resources.cokeprice"
(The quotation marks is not apart of the code)

kanyonb38
Newbie Poster
9 posts since Nov 2011
Reputation Points: 10
Solved Threads: 0
 

There should be examples in the Help file. Post what code you have and we can point to issues/errors, but we won't write it for you.

BitBlt
Master Poster
711 posts since Feb 2011
Reputation Points: 367
Solved Threads: 109
 

I am making a invoice program and I tried multiplying the number of times clicked which is in a text box and the price of the item which is is my resources. I already have the code to count how many times the button is clicked. Please Help!!

Thank you so much in advance!!

This is the code for counting how many times a button is pressed

Static hits1 As Integer
        hits1 += 1
        Numberofwater.Text = hits1.ToString("n0")


So far I don't have any code that works for multiplying. I understand that you won't write the code for me. Thanks for guiding me in the right direction though.

kanyonb38
Newbie Poster
9 posts since Nov 2011
Reputation Points: 10
Solved Threads: 0
 

I am making a invoice program and I tried multiplying the number of times clicked which is in a text box and the price of the item which is is my resources. I already have the code to count how many times the button is clicked. Please Help!!

Thank you so much in advance!!


I though I had it this time, but when I press the button it ads two for some reason. Numberofcoke, numberofcoffee and numberofwater are how many times I press each button.

P.S. If you haven't already figured it out, this is a restaurant POS software. Dim str1 As String
Dim num1 As Integer
Dim str2 As String
Dim num2 As Integer
Dim str3 As String
Dim num3 As Integer
Dim str4 As String
Dim num4 As Integer
Dim str5 As String
Dim num5 As Integer
Dim str6 As String
Dim num6 As Integer

str1 = Numberofcoke.Text
num1 = Val(str1)
str2 = "2.25"
num2 = Val(str2)
str3 = numberofcoffee.Text
num3 = Val(str3)
str4 = "1.50"
num4 = Val(str4)
str5 = Numberofwater.Text
num5 = Val(str5)
str6 = "0.00"
num6 = Val(str6)

subtotal.Text = num1 * num2 + num3 * num4 + num5 * num6

kanyonb38
Newbie Poster
9 posts since Nov 2011
Reputation Points: 10
Solved Threads: 0
 

That's because you are using integer datatypes. You need to change the datatypes of num1, num2, etc. to something that supports a decimal point (like "Single" or "Double").

BitBlt
Master Poster
711 posts since Feb 2011
Reputation Points: 367
Solved Threads: 109
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You