6 Years
Discussion Span
Last Post by P.manidas

I am posting whole codes of my project for easy reading. And if somebody want to see the project with form and control please download the attachment from my above post.

Dim WithEvents TxtBox As TextBox
Dim WithEvents LblLabel As Label
Dim NoOfControl As Integer
Dim A As Integer

Private Sub AddFromCreatedTextBox_Click()
'what will be the codes here
End Sub

Private Sub CmdLoadTextBox_Click()
Dim TopPosition As Integer

NoOfControl = Val(Trim(Text1.Text))

If NoOfControl <= 7 Then
    TopPosition = 3000

    For A = 1 To NoOfControl Step 1
        Set LblLabel = Me.Controls.Add("vb.Label", "DLabel" + Trim(Str(A)))
        With LblLabel
            .Left = 500
            .Top = TopPosition
            .Width = 2000
            .Height = 700
            .Visible = True
            .Caption = "Enter Number on Text Box"
            .DragMode = 0
        End With
        Set TxtBox = Me.Controls.Add("vb.TextBox", "TxtBox" + Trim(Str(A)))
        With TxtBox
            .Left = 3000
            .Top = TopPosition
            .Width = 1000
            .Height = 500
            .Visible = True
            .DragMode = 0
        End With
        TopPosition = TopPosition + 1000
    Next A

    MsgBox "You can't create here more than 7 controls"
    Exit Sub
End If

End Sub

Edited by P.manidas: n/a


I have got the result/solution from Microsoft Visual Basic Developer Center. The answer has given by respected sir "Calle Mellergardh". And the codes are ...

Private Sub AddFromCreatedTextBox_Click()
'what will be the codes here
Dim ctl As Control
    Dim num As Integer
    Dim total As Integer
    For Each ctl In Me.Controls
        If TypeOf ctl Is TextBox And InStr(ctl.Name, "TxtBox") <> 0 Then
            num = Val(Trim(ctl.Text))
            total = total + num
        End If
    MsgBox total
End Sub
Votes + Comments
thank you for shairing.
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.