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 05:20 PM.
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
JG
... If your problem is fixed don't forget to mark your threads as resolved using the Thread Tools menu ...
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
JG
... If your problem is fixed don't forget to mark your threads as resolved using the Thread Tools menu ...
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
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.