TextBoxのテキストを取得/設定するにはTextプロパティを使用します。
下記はテキストを取得設定する例です。
VBの例
' フォームロード時の処理
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'★★★テキストを設定★★★
TextBox1.Text = "これはTextBoxです"
End Sub
' [取得]ボタンクリック時の処理
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'★★★TextBoxのテキストを取得★★★
Dim strText As String = TextBox1.Text
MessageBox.Show(strText)
End Sub
C#の例
// フォームロード時の処理
private void Form1_Load(object sender, EventArgs e)
{
// ★★★テキストを設定★★★
textBox1.Text = "これはTextBoxです";
}
// [取得]ボタンクリック時の処理
private void button1_Click(object sender, EventArgs e)
{
//★★★TextBoxのテキストを取得★★★
string strText = textBox1.Text;
MessageBox.Show(strText);
}
Please follow and like us:


コメント
[…] テキストを取得/設定する […]