Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 84
Default What is better Variables or TextBox ?

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default What is better Variables or TextBox ?


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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default What is better Variables or TextBox ?

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

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.


In VBA, assigning floating point numbers to a variable declared as Integer
or Long will round the values (using "Banker's Rounding") to a whole number,
not truncate them.

Rick

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default What is better Variables or TextBox ?

It would be faster to have the textbox results pasted to the worksheet and
do the have the formulas in your worksheet and then copy and paste speacial
the results where you want them. ie:

sheets("sheet1").range("a1").select
selection.contents=me.sbad.value
sheets(sheet1").range("a2").select
selection.contents = me.cad.value


Shawn


"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


  #5   Report Post  
Posted to microsoft.public.excel.programming
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




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

Shawn,

My problem is not the formulas, because I have a Calculation Button in the
userform, so i click that one and displays all the results, where is taking
to long is to paste those results to the excel worksheet.

Once the results are in the userform displays I use the following:

Private Sub cdmexcel_Click()
Dim b As Worksheet
Set b = Worksheets("Report")
With b
.Cells(3, 1).Value = Me.textnombre.Value
.Cells(4, 1).Value = Me.textpuesto.Value
.Cells(11, 2).Value = Me.sbm.Value

And son all the textboxes with results and put them in the code above to
copy it to the worksheet.

This is what is taking to long, to just copy and past the result of a
textbox (which is already there) into the worksheet

Do you know a better way o faster way to COPY and PASTE a value from a
textbox to the worksheet?

Or is just taking to long because they are like a 100 values to copy ?

Thanks a lot !!
Carlos
Monterrey, Mexico

"Shawn" wrote:

It would be faster to have the textbox results pasted to the worksheet and
do the have the formulas in your worksheet and then copy and paste speacial
the results where you want them. ie:

sheets("sheet1").range("a1").select
selection.contents=me.sbad.value
sheets(sheet1").range("a2").select
selection.contents = me.cad.value


Shawn


"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


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default What is better Variables or TextBox ?

Just an idea, if your userform isn't too complex, replace it with a
set of Forms controls, where each control can be linked to a cell.
Then the time of each value being put into its cell is hidden behind
the time you are navigating around the various controls. If you
judiciously select the location of the linked cells, you can pick them
up with an array and do lots of calcutions and validations in memory.

Carl.

On Jul 31, 9:08 am, Carlos wrote:
Shawn,

My problem is not the formulas, because I have a Calculation Button in the
userform, so i click that one and displays all the results, where is taking
to long is to paste those results to the excel worksheet.

Once the results are in the userform displays I use the following:

Private Sub cdmexcel_Click()
Dim b As Worksheet
Set b = Worksheets("Report")
With b
.Cells(3, 1).Value = Me.textnombre.Value
.Cells(4, 1).Value = Me.textpuesto.Value
.Cells(11, 2).Value = Me.sbm.Value

And son all the textboxes with results and put them in the code above to
copy it to the worksheet.

This is what is taking to long, to just copy and past the result of a
textbox (which is already there) into the worksheet

Do you know a better way o faster way to COPY and PASTE a value from a
textbox to the worksheet?

Or is just taking to long because they are like a 100 values to copy ?

Thanks a lot !!
Carlos
Monterrey, Mexico



"Shawn" wrote:
It would be faster to have the textbox results pasted to the worksheet and
do the have the formulas in your worksheet and then copy and paste speacial
the results where you want them. ie:


sheets("sheet1").range("a1").select
selection.contents=me.sbad.value
sheets(sheet1").range("a2").select
selection.contents = me.cad.value


Shawn


"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- Hide quoted text -


- Show quoted text -



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
HELP! I Lost The Ability To Advance From TextBox To TextBox With the ENTER Or The TAB Keys Minitman[_4_] Excel Programming 0 February 22nd 05 08:50 PM
Textbox Bug? Missing/delayed update of textbox filled via VBA MarcM Excel Programming 0 November 4th 04 05:47 PM
Textbox Bug? Missing/delayed update of textbox filled via VBA MarcM Excel Programming 0 November 4th 04 05:43 PM
How to move cursor from one textbox control to another textbox con Tom Ogilvy Excel Programming 1 September 16th 04 03:42 PM
Assign a variables value to a TextBox ed Excel Programming 1 October 25th 03 08:41 PM


All times are GMT +1. The time now is 07:24 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"