[RESOLVED] How to calculate the total sum of the numbers - Page 2
 CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com

# Thread: [RESOLVED] How to calculate the total sum of the numbers

1. Senior Member
Join Date
Jul 2005
Posts
1,080

## Re: [RESOLVED] How to calculate the total sum of the numbers

The character _ means continuation line... just press Enter after _ and continue typing next line of code

2. ## Re: [RESOLVED] How to calculate the total sum of the numbers

I have another question for you.

For each 8 textbox i can enter any number i want.(from 0 to 9)
But how to do that on each textbox i can enter specific number? For example:

And i notice a mistake, look at this picture.

My C-button clear all textbox and leave them blank.

My code is this:

Code:
```
Dim intTotal1 As Integer
Dim strTotal1 As String
Dim intTotal2 As Integer

Private Sub Command1_Click()
If IsNumeric(Text1.Text) And _
IsNumeric(Text2.Text) And _
IsNumeric(Text3.Text) And _
IsNumeric(Text4.Text) And _
IsNumeric(Text5.Text) And _
IsNumeric(Text6.Text) And _
IsNumeric(Text7.Text) And _
IsNumeric(Text8.Text) Then
intTotal1 = Val(Text1.Text) + Val(Text2.Text) + Val(Text3.Text) + Val(Text4.Text) + Val(Text5.Text) + Val(Text6.Text) + Val(Text7.Text) + Val(Text8.Text)
strTotal1 = Format(intTotal1, "00")
intTotal2 = Val(Left(strTotal1, 1)) + Val(Right(strTotal1, 1))
Label1.Caption = Format(intTotal2)
Else
MsgBox "Laukelis paliktas tuščias arba įvestas ne skaičius!", vbInformation, "Dėmesio!"
End If
End Sub

Private Sub Command2_Click()
Dim Contrl As Control
For Each Contrl In Form1.Controls
If (TypeOf Contrl Is TextBox) Then Contrl.Text = ""
End Sub```
Last edited by Halosar7; October 5th, 2012 at 06:20 PM.

3. Senior Member
Join Date
Jul 2005
Posts
1,080

## Re: [RESOLVED] How to calculate the total sum of the numbers

Code:
```Dim intTotal1 As Integer
Dim strTotal1 As String
Dim intTotal2 As Integer
Dim strTotal2 As String

Private Sub Command1_Click()
If IsNumeric(Text1.Text) And _
IsNumeric(Text2.Text) And _
IsNumeric(Text3.Text) And _
IsNumeric(Text4.Text) And _
IsNumeric(Text5.Text) And _
IsNumeric(Text6.Text) And _
IsNumeric(Text7.Text) And _
IsNumeric(Text8.Text) Then
If Val(Text1.Text) <> 1 And Val(Text1.Text) <> 2 Then
MsgBox "Year must begin with 1 or 2"
Exit Sub
End If
If Val(Text5.Text & Text6.Text) < 1 Or _
Val(Text5.Text & Text6.Text) > 12 Then
MsgBox "Month must be between 01 and 12"
Exit Sub
End If
If Val(Text7.Text & Text8.Text) < 1 Or _
Val(Text7.Text & Text8.Text) > 31 Then
MsgBox "Day must be between 01 and 31"
Exit Sub
End If
intTotal1 = Val(Text1.Text) + Val(Text2.Text) + Val(Text3.Text) + Val(Text4.Text) + Val(Text5.Text) + Val(Text6.Text) + Val(Text7.Text) + Val(Text8.Text)
strTotal1 = Format(intTotal1, "00")
intTotal2 = Val(Left(strTotal1, 1)) + Val(Right(strTotal1, 1))
If intTotal2 > 9 Then
strTotal2 = Format(intTotal2, "00")
intTotal2 = Val(Left(strTotal2, 1)) + Val(Right(strTotal2, 1))
End If
Label1.Caption = Format(intTotal2)
Else
MsgBox "Laukelis paliktas tuščias arba įvestas ne skaičius!", vbInformation, "Dėmesio!"
End If
End Sub

Private Sub Command2_Click()

Dim Contrl As Control

For Each Contrl In Form1.Controls
If (TypeOf Contrl Is TextBox) Then
Contrl.Text = ""
End If
Next

End Sub```

4. ## Re: [RESOLVED] How to calculate the total sum of the numbers

add another line of code. that's what _ means

5. ## Re: [RESOLVED] How to calculate the total sum of the numbers

Originally Posted by dglienna
add another line of code. that's what _ means
It means that we continue programing by fixing bug and i ask him about vb6 programing. That way i learning from his code.
Last edited by Halosar7; October 6th, 2012 at 07:00 PM.

6. Senior Member
Join Date
Jul 2005
Posts
1,080

## Re: [RESOLVED] How to calculate the total sum of the numbers

Iy would be better if you start a new thread about transparency in VB6... anyway
Here's a small VB6 project about transparent form
I think this is better than explain here

7. ## Re: [RESOLVED] How to calculate the total sum of the numbers

Originally Posted by jggtz
Iy would be better if you start a new thread about transparency in VB6... anyway
Here's a small VB6 project about transparent form
I think this is better than explain here
Thanks :-)

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•