Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Sum numbers in userform


Hi there
i use userform to sum the entered numbers into the same userform


Code:
--------------------
Private Sub CommandButton1_Click()

If Label1.Caption = "" Then

Label1.Caption = TextBox1.Value
TextBox2.Value = TextBox1.Value

Else:
Label1.Caption = Label1.Caption & vbCr
Label1.Caption = Label1.Caption & TextBox1.Value
TextBox2.Value = TextBox2.Value + TextBox1.Value

End If

TextBox1.Value = ""

End Sub
--------------------



but this line:

Code:
--------------------
TextBox2.Value = TextBox2.Value + TextBox1.Value
--------------------


put the numeric values next to each other

i need to sum them insted ?


--
helmekki


------------------------------------------------------------------------
helmekki's Profile: http://www.excelforum.com/member.php...fo&userid=6939
View this thread: http://www.excelforum.com/showthread...hreadid=486630

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Sum numbers in userform

Hi Helmekki,

but this line:

Code:
--------------------
TextBox2.Value = TextBox2.Value + TextBox1.Value
--------------------


put the numeric values next to each other

i need to sum them insted ?


Try:

TextBox2.Value = CDbl(TextBox2.Value) + CDbl(TextBox1.Value)


---
Regards,
Norman



"helmekki" wrote in
message ...

Hi there
i use userform to sum the entered numbers into the same userform


Code:
--------------------
Private Sub CommandButton1_Click()

If Label1.Caption = "" Then

Label1.Caption = TextBox1.Value
TextBox2.Value = TextBox1.Value

Else:
Label1.Caption = Label1.Caption & vbCr
Label1.Caption = Label1.Caption & TextBox1.Value
TextBox2.Value = TextBox2.Value + TextBox1.Value

End If

TextBox1.Value = ""

End Sub
--------------------



but this line:

Code:
--------------------
TextBox2.Value = TextBox2.Value + TextBox1.Value
--------------------


put the numeric values next to each other

i need to sum them insted ?


--
helmekki


------------------------------------------------------------------------
helmekki's Profile:
http://www.excelforum.com/member.php...fo&userid=6939
View this thread: http://www.excelforum.com/showthread...hreadid=486630



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Sum numbers in userform


i tried with this code:

Code:
--------------------
Private Sub CommandButton1_Click()
Dim tooo As Double
Dim vtt As Double

If Label1.Caption = "" Then
Label1.Caption = vtt.Value
tooo.Value = vtt.Value

Else:
Label1.Caption = Label1.Caption & vbCr
Label1.Caption = Label1.Caption & vtt
tooo.Value = CDbl(tooo) + CDbl(vtt)


End If

tooo.Value = ""

End Sub
--------------------

but it gives me invaled qualifier when tring to read vtt

any idea how to solve the problem ?


--
helmekki


------------------------------------------------------------------------
helmekki's Profile: http://www.excelforum.com/member.php...fo&userid=6939
View this thread: http://www.excelforum.com/showthread...hreadid=486630

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Sum numbers in userform

Since vtt is an intrinsic data type (a double), it doesn't have
any properties. Your code

tooo.Value = vtt.Value
is wrong. It should be
tooo = vtt

The code

tooo.Value = CDbl(tooo) + CDbl(vtt)
is also wrong. First, you can't have a Value property, and since
tooo and vtt are declared as double, you don't need the CDbl
function at all.
tooo= tooo + vtt


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"helmekki"
wrote in
message
...

i tried with this code:

Code:
--------------------
Private Sub CommandButton1_Click()
Dim tooo As Double
Dim vtt As Double

If Label1.Caption = "" Then
Label1.Caption = vtt.Value
tooo.Value = vtt.Value

Else:
Label1.Caption = Label1.Caption & vbCr
Label1.Caption = Label1.Caption & vtt
tooo.Value = CDbl(tooo) + CDbl(vtt)


End If

tooo.Value = ""

End Sub
--------------------

but it gives me invaled qualifier when tring to read vtt

any idea how to solve the problem ?


--
helmekki


------------------------------------------------------------------------
helmekki's Profile:
http://www.excelforum.com/member.php...fo&userid=6939
View this thread:
http://www.excelforum.com/showthread...hreadid=486630



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Sum numbers in userform


I made some correction, but still got type mismatch in the line

CDbl(tooo.Value)

here is the whole code


Code:
--------------------

Private Sub CommandButton1_Click()
Dim cdbltooo As Double
Dim cdbltotv As Double

If Label1.Caption = "" Then
Label1.Caption = totv.Value
tooo.Value = CDbl(totv.Value)

Else:
Label1.Caption = Label1.Caption & vbCr
Label1.Caption = Label1.Caption & totv.Value
tooo.Value = CDbl(tooo.Value) + CDbl(totv)


End If

tooo.Value = ""

End Sub
--------------------


--
helmekki


------------------------------------------------------------------------
helmekki's Profile: http://www.excelforum.com/member.php...fo&userid=6939
View this thread: http://www.excelforum.com/showthread...hreadid=486630



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Sum numbers in userform

Did you read my reply? You still have .Value on your totv and
tooo variables. This WILL NOT WORK. Get rid of the .Value's. And
you don't need the CDbl functions because your variables are
already doubles.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"helmekki"
wrote in
message
...

I made some correction, but still got type mismatch in the line

CDbl(tooo.Value)

here is the whole code


Code:
--------------------

Private Sub CommandButton1_Click()
Dim cdbltooo As Double
Dim cdbltotv As Double

If Label1.Caption = "" Then
Label1.Caption = totv.Value
tooo.Value = CDbl(totv.Value)

Else:
Label1.Caption = Label1.Caption & vbCr
Label1.Caption = Label1.Caption & totv.Value
tooo.Value = CDbl(tooo.Value) + CDbl(totv)


End If

tooo.Value = ""

End Sub
--------------------


--
helmekki


------------------------------------------------------------------------
helmekki's Profile:
http://www.excelforum.com/member.php...fo&userid=6939
View this thread:
http://www.excelforum.com/showthread...hreadid=486630



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Sum numbers in userform


Ok , i did what you said, but it did not work with me .
still tooo TextBox does not show the total amount entered in vtt each
time i enter a new number.............
i need the tooo to show the total of numbers entered into vtt each
time

here is the code and please find the attached file


Code:
--------------------
Private Sub CommandButton1_Click()
Dim tooo As Double
Dim vtt As Double

If Label1.Caption = "" Then
Label1.Caption = vtt
tooo = vtt

Else:
Label1.Caption = Label1.Caption & vbCr
Label1.Caption = Label1.Caption & vtt
tooo = tooo + vtt

End If
tooo = ""

End Sub
--------------------


--
helmekki


------------------------------------------------------------------------
helmekki's Profile: http://www.excelforum.com/member.php...fo&userid=6939
View this thread: http://www.excelforum.com/showthread...hreadid=486630

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Sum numbers in userform

Your last command is

tooo = ""

so it you clear whatever it may have shown from the earlier code.

Also, don't dimension tooo as Double if it is a textbox. Don't dimension it
at all.

Assuming tooo and vtt are textboxes on your form

Private Sub CommandButton1_Click()

If Label1.Caption = "" Then
Label1.Caption = vtt
tooo.Value = vtt.Value

Else:
Label1.Caption = Label1.Caption & vbCr
Label1.Caption = Label1.Caption & vtt
tooo.Value = val(tooo.value) + val(vtt.Value)

End If
End Sub

--
Regards,
Tom Ogilvy



"helmekki" wrote in
message ...

Ok , i did what you said, but it did not work with me .
still tooo TextBox does not show the total amount entered in vtt each
time i enter a new number.............
i need the tooo to show the total of numbers entered into vtt each
time

here is the code and please find the attached file


Code:
--------------------
Private Sub CommandButton1_Click()
Dim tooo As Double
Dim vtt As Double

If Label1.Caption = "" Then
Label1.Caption = vtt
tooo = vtt

Else:
Label1.Caption = Label1.Caption & vbCr
Label1.Caption = Label1.Caption & vtt
tooo = tooo + vtt

End If
tooo = ""

End Sub
--------------------


--
helmekki


------------------------------------------------------------------------
helmekki's Profile:

http://www.excelforum.com/member.php...fo&userid=6939
View this thread: http://www.excelforum.com/showthread...hreadid=486630



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Sum numbers in userform


Tom Ogilvy, realy thank u veru much it worked great for me


--
helmekki


------------------------------------------------------------------------
helmekki's Profile: http://www.excelforum.com/member.php...fo&userid=6939
View this thread: http://www.excelforum.com/showthread...hreadid=486630

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
Looping procedure calls userform; how to exit loop (via userform button)? KR Excel Programming 6 July 27th 05 12:57 PM
Max numbers of characters in userform textbox and cell N E Body Excel Programming 4 June 27th 05 06:25 PM
Activating userform and filling it with data form row where userform is activate Marthijn Beusekom via OfficeKB.com[_2_] Excel Programming 3 May 6th 05 05:44 PM
Access from add_in userform to main template userform.... Ajit Excel Programming 1 November 18th 04 05:15 PM
add numbers in textboxes on userform KimberlyC Excel Programming 5 September 18th 03 06:15 AM


All times are GMT +1. The time now is 06:55 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"