|
分類:[VB.NET/VB2005 以降]
Private number As Integer Private rows As Integer Private columns As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load For i As Integer = 1 To 3 AddHandler Me.Controls("TextBox" & i).TextChanged, AddressOf TextBox_TextChanged Next End Sub
Private Sub TextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
If System.Text.RegularExpressions.Regex.IsMatch(CType(sender, TextBox).Text, "[^0-9]") Then MessageBox.Show("数字で入力してください", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
With CType(sender, TextBox) .Text = .Text.Substring(0, .Text.Length - 1) .SelectionStart = .Text.Length End With End If Dim cnt As Integer
If Integer.TryParse(TextBox1.Text, cnt) And Integer.TryParse(TextBox2.Text, cnt) And Integer.TryParse(TextBox3.Text, cnt) Then For i = 1 To cnt
Dim tb As TextBox = New TextBox() tb.Name = "tb" + i.ToString() Me.Controls.Add(tb) tb.Top = (i - 1) * 28 + 55 * i tb.Left = 30 tb.Width = 25 Next End If End Sub
TextBox1、TextBox2、TextBox3全てに数字が入った場合それだけ分のテキストボックスを表示させたいのですがうまくいきません。 例えば 3 3 3と入力されれば 3×3×3分のテキストボックスを表示させたいです。
|