CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 22 of 22
  1. #16
    Join Date
    Jul 2005
    Posts
    1,083

    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
    JG


    ... If your problem is fixed don't forget to mark your threads as resolved using the Thread Tools menu ...

  2. #17
    Join Date
    Oct 2012
    Posts
    59

    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:

    Name:  eer.jpg
Views: 766
Size:  29.0 KB


    And i notice a mistake, look at this picture.

    Name:  nett.jpg
Views: 765
Size:  46.5 KB

    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.

  3. #18
    Join Date
    Jul 2005
    Posts
    1,083

    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 ...

  4. #19
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

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

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

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  5. #20
    Join Date
    Oct 2012
    Posts
    59

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

    Quote Originally Posted by dglienna View Post
    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.
    Attached Images Attached Images  
    Last edited by Halosar7; October 6th, 2012 at 06:00 PM.

  6. #21
    Join Date
    Jul 2005
    Posts
    1,083

    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
    Attached Files Attached Files
    JG


    ... If your problem is fixed don't forget to mark your threads as resolved using the Thread Tools menu ...

  7. #22
    Join Date
    Oct 2012
    Posts
    59

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

    Quote Originally Posted by jggtz View Post
    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 :-)

Page 2 of 2 FirstFirst 12

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured