Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() I am trying to write a code to calculate efficiency of a process. Th following code gives me "Object Required' Error Please educate me. Private Sub CommandButton1_Click() Dim NetLoad As Variant Dim AveCoatWt As Variant Dim WtGain As Variant Dim solutionapplied As Variant NetLoad.Value = TextBox1.Text AveCoatWt.Value = TextBox2.Text WtGain.Value = TextBox3.Text solutiionapplied.Value = TextBox4.Text TextBox5.Value = (TextBox4 / ((TextBox1 * TextBox2 * 1000000) TextBox3)) End Sub Thank you for your help. Sye -- sazi ----------------------------------------------------------------------- saziz's Profile: http://www.excelforum.com/member.php...nfo&userid=635 View this thread: http://www.excelforum.com/showthread.php?threadid=47720 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You declared these things:
Dim NetLoad As Variant Dim AveCoatWt As Variant Dim WtGain As Variant Dim solutionapplied As Variant But you never set them to anything. What are they? saziz wrote: I am trying to write a code to calculate efficiency of a process. The following code gives me "Object Required' Error Please educate me. Private Sub CommandButton1_Click() Dim NetLoad As Variant Dim AveCoatWt As Variant Dim WtGain As Variant Dim solutionapplied As Variant NetLoad.Value = TextBox1.Text AveCoatWt.Value = TextBox2.Text WtGain.Value = TextBox3.Text solutiionapplied.Value = TextBox4.Text TextBox5.Value = (TextBox4 / ((TextBox1 * TextBox2 * 1000000) * TextBox3)) End Sub Thank you for your help. Syed -- saziz ------------------------------------------------------------------------ saziz's Profile: http://www.excelforum.com/member.php...fo&userid=6350 View this thread: http://www.excelforum.com/showthread...hreadid=477205 -- Dave Peterson |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hi Dave, The values for those are being input through textboxes. Sye -- sazi ----------------------------------------------------------------------- saziz's Profile: http://www.excelforum.com/member.php...nfo&userid=635 View this thread: http://www.excelforum.com/showthread.php?threadid=47720 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Then those things are just holders for the values from the textboxes?
If yes, then each of those things will hold a string -- until/unless you convert it to something else. And since you're doing arithmetic with them, maybe... Private Sub CommandButton1_Click() Dim NetLoad As double Dim AveCoatWt As double Dim WtGain As double Dim solutionapplied As double NetLoad = cdbl(TextBox1.Text) AveCoatWt = cdbl(TextBox2.Text) WtGain = cdbl(TextBox3.Text) solutionapplied = cdbl(TextBox4.Text) TextBox5.Value = (TextBox4 / ((TextBox1 * TextBox2 * 1000000) * TextBox3)) End Sub These are simple variables--not objects (like ranges, which have a .value property). saziz wrote: Hi Dave, The values for those are being input through textboxes. Syed -- saziz ------------------------------------------------------------------------ saziz's Profile: http://www.excelforum.com/member.php...fo&userid=6350 View this thread: http://www.excelforum.com/showthread...hreadid=477205 -- Dave Peterson |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Dave, Thank you for the help. What could be the format for % for textbox5 value? I am trying this: textbox5.text=format( formula, "%") It gives me error. Thnaks once again for your help. Syed -- saziz ------------------------------------------------------------------------ saziz's Profile: http://www.excelforum.com/member.php...fo&userid=6350 View this thread: http://www.excelforum.com/showthread...hreadid=477205 |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Maybe...
textbox5.text=format( formula, "0.00%") And you may not need those intermediate variables, too: Option Explicit Private Sub CommandButton1_Click() TextBox5.Value _ = Format((Me.TextBox4.Value _ / ((Me.TextBox1.Value * Me.TextBox2.Value * 1000000) _ * Me.TextBox3.Value)), "0.0%") End Sub But I would add some checks for numbers for each of those textboxes. saziz wrote: Dave, Thank you for the help. What could be the format for % for textbox5 value? I am trying this: textbox5.text=format( formula, "%") It gives me error. Thnaks once again for your help. Syed -- saziz ------------------------------------------------------------------------ saziz's Profile: http://www.excelforum.com/member.php...fo&userid=6350 View this thread: http://www.excelforum.com/showthread...hreadid=477205 -- Dave Peterson |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Dave, Thank you for the help. What could be the format for % for textbox5 value? I am trying this: textbox5.text=format( formula, "%") It gives me error. Thnaks once again for your help. Sye -- sazi ----------------------------------------------------------------------- saziz's Profile: http://www.excelforum.com/member.php...nfo&userid=635 View this thread: http://www.excelforum.com/showthread.php?threadid=47720 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|