私は.NETプログラミングの初心者です。
Button1_Clickイベントを含むクラスForm1があります。(Button1_Clickは、実行時に複数のテキストボックスを作成します)
クラスは次のとおりです。
Public Class Form1
Dim shiftDown As Integer
Dim counter As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim textbox1 As New TextBox
counter += 1
shiftDown = shiftDown + 30
textbox1.Name = "Textbox" + counter.ToString()
textbox1.Size = New Size(170, 10)
textbox1.Location = New Point(10, 32 + shiftDown)
textbox1.Visible = True
GroupBox1.Controls.Add(textbox1)
End Sub
エンドクラス
現在、この行:
Dim shiftDown As Integer
整数としての薄暗いカウンター
グローバル変数として定義されます。
私の質問は、これらの変数をプロパティとして定義するか、Button1_Clickイベントの静的ローカル変数として定義する必要があるかということです。