|
|
| Next: Outlook 2007 add-ins causing problems with IMAP |
| Author |
Message |
Susan External

Since: Apr 18, 2007 Posts: 33
|
Posted: Mon Sep 28, 2009 7:30 am Post subject: adding values in userform Archived from groups: microsoft>public>word>vba>userforms (more info?) |
|
|
on my userform i have
txtMonthlyRent
and
txtAnnualRent
i need the monthly rent multiplied times 12 to automatically fill in
the txtAnnualRent box.
this is what i've got so far (after trying many variations):
****************************************
Private Sub txtAnnualRent_Enter()
myMonthlyRent = txtMonthlyRent.Value
myMonthlyRent = myMonthlyRent * 12
End Sub
****************************************
i've tried myMonthlyRent.Formula but that won't work either.
If somebody could help me i'd be very appreciative!
thanks
susan |
|
| Back to top |
|
 |
Susan External

Since: Apr 18, 2007 Posts: 33
|
Posted: Mon Sep 28, 2009 8:35 am Post subject: Re: adding values in userform [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
thanks a lot graham & greg! i went with greg's code because it fit
better in my project.
thank you!
susan
On Sep 28, 10:45 am, "Greg Maxey"
<gma....TakeThisOut@mIKEvICTORpAPAsIERRA.oSCARrOMEOgOLF> wrote:
> Susan,
>
> I would probably leave txtAnnualRent disabled and do the calculation OnExit
> from txtMonthlyRent:
>
> Private Sub txtMonthlyRent_Exit(ByVal Cancel As MSForms.ReturnBoolean)
> If IsNumeric(Me.txtMonthlyRent) Then
> Me.txtAnnualRent.Value = Format(12 * CDbl(Me.txtMonthlyRent.Value),
> "$#,##0.00")
> Else
> Cancel = True
> End If
> End Sub
>
> --
> Greg Maxey
>
> See my web sitehttp://gregmaxey.mvps.org
> for an eclectic collection of Word Tips.
>
> "It is not the critic who counts, not the man who points out how the strong
> man stumbles, or where the doer of deeds could have done them better. The
> credit belongs to the man in the arena, whose face is marred by dust and
> sweat and blood, who strives valiantly...who knows the great enthusiasms,
> the great devotions, who spends himself in a worthy cause, who at the best
> knows in the end the triumph of high achievement, and who at the worst, if
> he fails, at least fails while daring greatly, so that his place shall never
> be with those cold and timid souls who have never known neither victory nor
> defeat." - TR
>
> "Susan" <bogenex....TakeThisOut@aol.com> wrote in message
>
> news:1a8af265-eee5-4245-9a84-199b3cdd8091@r31g2000vbi.googlegroups.com...
>
>
>
> > on my userform i have
>
> > txtMonthlyRent
> > and
> > txtAnnualRent
>
> > i need the monthly rent multiplied times 12 to automatically fill in
> > the txtAnnualRent box.
>
> > this is what i've got so far (after trying many variations):
> > ****************************************
> > Private Sub txtAnnualRent_Enter()
>
> > myMonthlyRent = txtMonthlyRent.Value
> > myMonthlyRent = myMonthlyRent * 12
>
> > End Sub
> > ****************************************
> > i've tried myMonthlyRent.Formula but that won't work either.
> > If somebody could help me i'd be very appreciative!
> > thanks
> > susan- Hide quoted text -
>
> - Show quoted text - |
|
| Back to top |
|
 |
Greg Maxey External

Since: Feb 01, 2009 Posts: 57
|
Posted: Mon Sep 28, 2009 10:45 am Post subject: Re: adding values in userform [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
Susan,
I would probably leave txtAnnualRent disabled and do the calculation OnExit
from txtMonthlyRent:
Private Sub txtMonthlyRent_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If IsNumeric(Me.txtMonthlyRent) Then
Me.txtAnnualRent.Value = Format(12 * CDbl(Me.txtMonthlyRent.Value),
"$#,##0.00")
Else
Cancel = True
End If
End Sub
--
Greg Maxey
See my web site http://gregmaxey.mvps.org
for an eclectic collection of Word Tips.
"It is not the critic who counts, not the man who points out how the strong
man stumbles, or where the doer of deeds could have done them better. The
credit belongs to the man in the arena, whose face is marred by dust and
sweat and blood, who strives valiantly...who knows the great enthusiasms,
the great devotions, who spends himself in a worthy cause, who at the best
knows in the end the triumph of high achievement, and who at the worst, if
he fails, at least fails while daring greatly, so that his place shall never
be with those cold and timid souls who have never known neither victory nor
defeat." - TR
"Susan" <bogenexcel.DeleteThis@aol.com> wrote in message
news:1a8af265-eee5-4245-9a84-199b3cdd8091@r31g2000vbi.googlegroups.com...
> on my userform i have
>
> txtMonthlyRent
> and
> txtAnnualRent
>
> i need the monthly rent multiplied times 12 to automatically fill in
> the txtAnnualRent box.
>
> this is what i've got so far (after trying many variations):
> ****************************************
> Private Sub txtAnnualRent_Enter()
>
> myMonthlyRent = txtMonthlyRent.Value
> myMonthlyRent = myMonthlyRent * 12
>
> End Sub
> ****************************************
> i've tried myMonthlyRent.Formula but that won't work either.
> If somebody could help me i'd be very appreciative!
> thanks
> susan |
|
| Back to top |
|
 |
Graham Mayor External

Since: Jul 04, 2006 Posts: 4676
|
Posted: Mon Sep 28, 2009 11:10 am Post subject: Re: adding values in userform [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
What I think you are asking for is:
Private Sub CommandButton1_Click()
Unload Me
myMonthlyRent = txtMonthlyRent.Value
MyAnnualRent = txtAnnualRent.Value
MsgBox "Monthly rent: " & myMonthlyRent & vbCr _
& "Annual Rent: " & MyAnnualRent
End Sub
Private Sub txtMonthlyRent_Change()
txtAnnualRent.Value = txtMonthlyRent.Value * 12
End Sub
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Susan wrote:
> on my userform i have
>
> txtMonthlyRent
> and
> txtAnnualRent
>
> i need the monthly rent multiplied times 12 to automatically fill in
> the txtAnnualRent box.
>
> this is what i've got so far (after trying many variations):
> ****************************************
> Private Sub txtAnnualRent_Enter()
>
> myMonthlyRent = txtMonthlyRent.Value
> myMonthlyRent = myMonthlyRent * 12
>
> End Sub
> ****************************************
> i've tried myMonthlyRent.Formula but that won't work either.
> If somebody could help me i'd be very appreciative!
> thanks
> susan |
|
| Back to top |
|
 |
|
|
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
| |
|
|