View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Carlos Carlos is offline
external usenet poster
 
Posts: 84
Default What is better Variables or TextBox ?

Thanks a lot !

I´m going to try to assign variables to all my values.

Thanks !!

"Jim Cone" wrote:


There is couple of guidelines you might be able to use...

1. If you use the same value more than twice then assign it to a variable.
2. Make sure you use the proper data type for the variables.
Using an integer data type for a numeric value truncates it to a whole number.
For wages/salaries/rates to be added to a worksheet - a Double data
type is appropriate.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)


"Carlos"
wrote in message
I have a Userform which does a LOT of calculatios but I´m using the direct
data from the Textboxes like this :

me.sbad.Value = Val(Me.sba) / Val(Me.tc)
me. cad.Value = Val(Me.ca) / Val(Me.tc)

Like these calculations I have a couple of hundred in the whole userform,
but then I have a button to display each result in a Worksheet, but it takes
for ever to copy it to the worksheet, well like 20 seconds, But still its a
lot of time just to copy and paste it to a worksheet.

I was wondering why is this happening ? and would it help if I use variables
for all the calculations instead of the textboxes. Like this:

Dim salary as integer
dim wage as integer
dim rate as integer

salary= me.sba.Value
wage= me. ca.Value
rate=me.tc.value

me.sbad.Value = salary / rate
me. cad.Value = wage / rate

Thanks