#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Userform

Hi All,

Can I add up in a text box in userform. For example the
user would type 10+12.50 in the text box and the text box
would show 22.50

Also how can I add up few text boxes into another one. Any
help is appreciated. Thanks in advance.

Regards
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default Userform

Private Sub TextBox1_AfterUpdate()
TextBox1.Text = Evaluate(TextBox1.Text)
End Sub

If you wanted to post the result into a different Textbox, say, TextBox2:
TextBox2.Text = Evaluate(TextBox1.Text)


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Silsila" wrote in message
...
Hi All,

Can I add up in a text box in userform. For example the
user would type 10+12.50 in the text box and the text box
would show 22.50

Also how can I add up few text boxes into another one. Any
help is appreciated. Thanks in advance.

Regards



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Userform

Hi Rob,

Thank you for your reply. The first code to sum up in the
textbox works fine. Thank you again.

The second code i tried as
TextBox3.Text = Evaluate(TextBox1.Text) + Evaluate
(TextBox2.Text)

does not work when either textbox1 or textbox2 is empty.

Thanks for your help.

Regards

-----Original Message-----
Private Sub TextBox1_AfterUpdate()
TextBox1.Text = Evaluate(TextBox1.Text)
End Sub

If you wanted to post the result into a different

Textbox, say, TextBox2:
TextBox2.Text = Evaluate(TextBox1.Text)


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Silsila" wrote in

message
...
Hi All,

Can I add up in a text box in userform. For example the
user would type 10+12.50 in the text box and the text

box
would show 22.50

Also how can I add up few text boxes into another one.

Any
help is appreciated. Thanks in advance.

Regards



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Userform

Dude, there is many ways to handle this sort of thing. This realy is basic stuff!
You say "does not work when either textbox1 or textbox2 is empty." - Check it!

The example you were given was a point in the right direction, you gotta check things
and handle exceptions like "textbox is empty", this is what you have to do to account for
people who try... "I wonder what will happen if i try to calculate..." "so and so + is a w@nker"
You know what i mean!

Sub DoMath()
dim r1, r2
on error goto FAIL
if TextBox1.Text = "" then
r1 = 0
else
r1 = Evaluate(TextBox1.Text)
End if

if TextBox2.Text = "" then
r2 = 0
else
r2 = Evaluate(TextBox3.Text)
End if

TextBox3.Text = r1 + r2

Exit Sub
FAIL:
msgbox "An error occured. Check your input"
End Sub

(TextBox2.Text)


"Silsila" wrote in message ...
Hi Rob,

Thank you for your reply. The first code to sum up in the
textbox works fine. Thank you again.

The second code i tried as
TextBox3.Text = Evaluate(TextBox1.Text) + Evaluate
(TextBox2.Text)

does not work when either textbox1 or textbox2 is empty.

Thanks for your help.

Regards

-----Original Message-----
Private Sub TextBox1_AfterUpdate()
TextBox1.Text = Evaluate(TextBox1.Text)
End Sub

If you wanted to post the result into a different

Textbox, say, TextBox2:
TextBox2.Text = Evaluate(TextBox1.Text)


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Silsila" wrote in

message
...
Hi All,

Can I add up in a text box in userform. For example the
user would type 10+12.50 in the text box and the text

box
would show 22.50

Also how can I add up few text boxes into another one.

Any
help is appreciated. Thanks in advance.

Regards



.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Userform

Man - dont you just hate it when you spot an error in yer own stuff!!!

Sub DoMath()

Dim r1, r2
On Error GoTo FAIL
If TextBox1.Text = "" Then
r1 = 0
Else
r1 = Evaluate(TextBox1.Text)
End If

If TextBox2.Text = "" Then
r2 = 0
Else
'''r2 = Evaluate(TextBox3.Text) ' <<<< incorrect - DOH
r2 = Evaluate(TextBox2.Text) ' <<<< Corerect :-)
End If

TextBox3.Text = r1 + r2

Exit Sub
FAIL:
MsgBox "An error occured. Check your input"

End Sub


"Stevie_mac" wrote in message ...
Dude, there is many ways to handle this sort of thing. This realy is basic stuff!
You say "does not work when either textbox1 or textbox2 is empty." - Check it!

The example you were given was a point in the right direction, you gotta check things
and handle exceptions like "textbox is empty", this is what you have to do to account for
people who try... "I wonder what will happen if i try to calculate..." "so and so + is a w@nker"
You know what i mean!

Sub DoMath()
dim r1, r2
on error goto FAIL
if TextBox1.Text = "" then
r1 = 0
else
r1 = Evaluate(TextBox1.Text)
End if

if TextBox2.Text = "" then
r2 = 0
else
r2 = Evaluate(TextBox3.Text)
End if

TextBox3.Text = r1 + r2

Exit Sub
FAIL:
msgbox "An error occured. Check your input"
End Sub

(TextBox2.Text)


"Silsila" wrote in message ...
Hi Rob,

Thank you for your reply. The first code to sum up in the
textbox works fine. Thank you again.

The second code i tried as
TextBox3.Text = Evaluate(TextBox1.Text) + Evaluate
(TextBox2.Text)

does not work when either textbox1 or textbox2 is empty.

Thanks for your help.

Regards

-----Original Message-----
Private Sub TextBox1_AfterUpdate()
TextBox1.Text = Evaluate(TextBox1.Text)
End Sub

If you wanted to post the result into a different

Textbox, say, TextBox2:
TextBox2.Text = Evaluate(TextBox1.Text)


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Silsila" wrote in

message
...
Hi All,

Can I add up in a text box in userform. For example the
user would type 10+12.50 in the text box and the text

box
would show 22.50

Also how can I add up few text boxes into another one.

Any
help is appreciated. Thanks in advance.

Regards


.







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Userform

Hi Stevie_mac,

Thank you for your help. Yes, eventually I will get to the
stage when I will feel comfortable exploring. Thanks.

Regards

-----Original Message-----
Man - dont you just hate it when you spot an error in yer

own stuff!!!

Sub DoMath()

Dim r1, r2
On Error GoTo FAIL
If TextBox1.Text = "" Then
r1 = 0
Else
r1 = Evaluate(TextBox1.Text)
End If

If TextBox2.Text = "" Then
r2 = 0
Else
'''r2 = Evaluate(TextBox3.Text) ' <<<< incorrect -

DOH
r2 = Evaluate(TextBox2.Text) ' <<<< Corerect :-)
End If

TextBox3.Text = r1 + r2

Exit Sub
FAIL:
MsgBox "An error occured. Check your input"

End Sub


"Stevie_mac" wrote in message

...
Dude, there is many ways to handle this sort of thing.

This realy is basic stuff!
You say "does not work when either textbox1 or textbox2

is empty." - Check it!

The example you were given was a point in the right

direction, you gotta check things
and handle exceptions like "textbox is empty", this is

what you have to do to account for
people who try... "I wonder what will happen if i try

to calculate..." "so and so + is a w@nker"
You know what i mean!

Sub DoMath()
dim r1, r2
on error goto FAIL
if TextBox1.Text = "" then
r1 = 0
else
r1 = Evaluate(TextBox1.Text)
End if

if TextBox2.Text = "" then
r2 = 0
else
r2 = Evaluate(TextBox3.Text)
End if

TextBox3.Text = r1 + r2

Exit Sub
FAIL:
msgbox "An error occured. Check your input"
End Sub

(TextBox2.Text)


"Silsila" wrote

in message ...
Hi Rob,

Thank you for your reply. The first code to sum up in

the
textbox works fine. Thank you again.

The second code i tried as
TextBox3.Text = Evaluate(TextBox1.Text) + Evaluate
(TextBox2.Text)

does not work when either textbox1 or textbox2 is

empty.

Thanks for your help.

Regards

-----Original Message-----
Private Sub TextBox1_AfterUpdate()
TextBox1.Text = Evaluate(TextBox1.Text)
End Sub

If you wanted to post the result into a different
Textbox, say, TextBox2:
TextBox2.Text = Evaluate(TextBox1.Text)


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Silsila"

wrote in
message
...
Hi All,

Can I add up in a text box in userform. For

example the
user would type 10+12.50 in the text box and the

text
box
would show 22.50

Also how can I add up few text boxes into another

one.
Any
help is appreciated. Thanks in advance.

Regards


.





.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Userform

specially when you've been a bit on the short side with
the questioner.
Regards Trev
-----Original Message-----
Man - dont you just hate it when you spot an error in yer

own stuff!!!

Sub DoMath()

Dim r1, r2
On Error GoTo FAIL
If TextBox1.Text = "" Then
r1 = 0
Else
r1 = Evaluate(TextBox1.Text)
End If

If TextBox2.Text = "" Then
r2 = 0
Else
'''r2 = Evaluate(TextBox3.Text) ' <<<< incorrect -

DOH
r2 = Evaluate(TextBox2.Text) ' <<<< Corerect :-)
End If

TextBox3.Text = r1 + r2

Exit Sub
FAIL:
MsgBox "An error occured. Check your input"

End Sub


"Stevie_mac" wrote in message

...
Dude, there is many ways to handle this sort of thing.

This realy is basic stuff!
You say "does not work when either textbox1 or textbox2

is empty." - Check it!

The example you were given was a point in the right

direction, you gotta check things
and handle exceptions like "textbox is empty", this is

what you have to do to account for
people who try... "I wonder what will happen if i try

to calculate..." "so and so + is a w@nker"
You know what i mean!

Sub DoMath()
dim r1, r2
on error goto FAIL
if TextBox1.Text = "" then
r1 = 0
else
r1 = Evaluate(TextBox1.Text)
End if

if TextBox2.Text = "" then
r2 = 0
else
r2 = Evaluate(TextBox3.Text)
End if

TextBox3.Text = r1 + r2

Exit Sub
FAIL:
msgbox "An error occured. Check your input"
End Sub

(TextBox2.Text)


"Silsila" wrote

in message ...
Hi Rob,

Thank you for your reply. The first code to sum up in

the
textbox works fine. Thank you again.

The second code i tried as
TextBox3.Text = Evaluate(TextBox1.Text) + Evaluate
(TextBox2.Text)

does not work when either textbox1 or textbox2 is

empty.

Thanks for your help.

Regards

-----Original Message-----
Private Sub TextBox1_AfterUpdate()
TextBox1.Text = Evaluate(TextBox1.Text)
End Sub

If you wanted to post the result into a different
Textbox, say, TextBox2:
TextBox2.Text = Evaluate(TextBox1.Text)


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Silsila"

wrote in
message
...
Hi All,

Can I add up in a text box in userform. For

example the
user would type 10+12.50 in the text box and the

text
box
would show 22.50

Also how can I add up few text boxes into another

one.
Any
help is appreciated. Thanks in advance.

Regards


.





.

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
UserForm grahammal Excel Discussion (Misc queries) 15 April 10th 06 06:01 PM
UserForm CR Excel Discussion (Misc queries) 1 August 10th 05 10:26 PM
Userform Help in VBC Marcia3641 Excel Discussion (Misc queries) 1 July 23rd 05 12:10 AM
UserForm John Beaumont Excel Programming 1 December 19th 03 04:41 PM
UserForm help Pete[_13_] Excel Programming 5 November 12th 03 02:12 AM


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