Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Userforms - Display result of a calculation in a textbox

I am creating a ueserform that shows asks the user to
enter a cost price and a selling price for an item.

Is ther a way of having another box (textbox?)which will
show the result of a calculation based upon the two
figures entered e.g Profit made in absolute and
percentage terms.

Thanks for your help
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Userforms - Display result of a calculation in a textbox

Garry

Code it as something like; Textbox3=textbox2-textbox1 and
Textbox4=textbox4/textbox3


Reagrds
Peter
-----Original Message-----
I am creating a ueserform that shows asks the user to
enter a cost price and a selling price for an item.

Is ther a way of having another box (textbox?)which will
show the result of a calculation based upon the two
figures entered e.g Profit made in absolute and
percentage terms.

Thanks for your help
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Userforms - Display result of a calculation in a textbox

Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim dblCost as Double, dblPrice as Double
if len(trim(textbox1.text)) 0 and len(trim(textbox2.text)) 0 then
if isnumeric(textbox1.text) and isnumeric(textbox2.text) then
dblCost = cdbl(textbox1.text)
dblPrice = cdbl(textbox2.text)
if dblPrice < 0 then
Textbox3.Text = Format(dblPrice-dblCost,"#,##0.00") & " - " & _
Format((dblPrice-dblCost)/dblPrice,"0.00%")
end if
end if
end if
End Sub

Private Sub TextBox2_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim dblCost as Double, dblPrice as Double
if len(trim(textbox1.text)) 0 and len(trim(textbox2.text)) 0 then
if isnumeric(textbox1.text) and isnumeric(textbox2.text) then
dblCost = cdbl(textbox1.text)
dblPrice = cdbl(textbox2.text)
if dblPrice < 0 then
Textbox3.Text = Format(dblPrice-dblCost,"#,##0.00") & " - " & _
Format((dblPrice-dblCost)/dblPrice,"0.00%")
end if
end if
end if
End Sub



--
Regards,
Tom Ogilvy

Gary Hall wrote in message
...
I am creating a ueserform that shows asks the user to
enter a cost price and a selling price for an item.

Is ther a way of having another box (textbox?)which will
show the result of a calculation based upon the two
figures entered e.g Profit made in absolute and
percentage terms.

Thanks for your help



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Userforms - Display result of a calculation in a textbox

Peter,

I get an error message when I try to insert the code.

I am inserting it into the Control Spurce box. Is this
right?

Gary


-----Original Message-----
Garry

Code it as something like; Textbox3=textbox2-textbox1 and
Textbox4=textbox4/textbox3


Reagrds
Peter
-----Original Message-----
I am creating a ueserform that shows asks the user to
enter a cost price and a selling price for an item.

Is ther a way of having another box (textbox?)which

will
show the result of a calculation based upon the two
figures entered e.g Profit made in absolute and
percentage terms.

Thanks for your help
.

.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Userforms - Display result of a calculation in a textbox

Garry

The code for a form goes in a special Form Module. You
probabley have a Command button on the form to process it.
Double click this button to open the Form Module. and
enter your code there. It will be attached to
Private Sub Button_Click.

If you are adding the data to a list in a sheet you can do
the code in the module and enter the values into a new
line.

If you want a demo form write direct.

regards
Peter
-----Original Message-----
Peter,

I get an error message when I try to insert the code.

I am inserting it into the Control Spurce box. Is this
right?

Gary


-----Original Message-----
Garry

Code it as something like; Textbox3=textbox2-textbox1 and
Textbox4=textbox4/textbox3


Reagrds
Peter
-----Original Message-----
I am creating a ueserform that shows asks the user to
enter a cost price and a selling price for an item.

Is ther a way of having another box (textbox?)which

will
show the result of a calculation based upon the two
figures entered e.g Profit made in absolute and
percentage terms.

Thanks for your help
.

.

.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Calculation Result Display Failure guy.yeon Excel Worksheet Functions 4 April 5th 07 08:56 PM
How do I use a rounded calculation result in another calculation? vnsrod2000 Excel Worksheet Functions 1 January 26th 05 10:11 PM
How do I use a rounded calculation result in another calculation? vnsrod2000 Excel Worksheet Functions 1 January 26th 05 09:36 PM
textbox result to label paradise Excel Programming 2 November 15th 03 01:10 PM
Creating Userforms and textbox numbers Bruccce Excel Programming 0 July 31st 03 04:22 AM


All times are GMT +1. The time now is 03:18 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"