0

I'm trying to make a program to make average of a number using combobox and a button. i made the combobox with number from 1 to 10 when it's change the program creates textboxes as the number. But i can get the text entered to be assigned to variables so i can complete the calculations

Public Class Form1
    Dim num As Integer = 1
    Private ReadOnly _Textboxes As New List(Of TextBox)
    Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
        _Textboxes.ForEach(New Action(Of TextBox)(AddressOf Controls.Remove))
        _Textboxes.Clear()
        num = ComboBox1.Text

        For i = 1 To num
            Dim TB As New TextBox
            TB.Size = New System.Drawing.Size(60, 20)
            TB.Font = New System.Drawing.Font("arial", 20)
            TB.Location = New Point(10, i * 40)
            TB.Name = "tbt" & i

            Select Case i
                Case 1 To 5
                    TB.Location = New Point(10, i * 45)
                Case 6 To 10
                    Dim i2 As Integer = i - 5
                    TB.Location = New Point(80, i2 * 45)
            End Select
            Controls.Add(TB)
            _Textboxes.Add(TB)
        Next
    End Sub
End Class

0 Answers0