0
は、私は文字列変数にテキストボックスのテキストを保存したい店舗のテキストボックスの値にしようとしているときにエラーが発生したが、エラーが発生します。System.NullReferenceException:オブジェクト参照がオブジェクトのインスタンスに設定されていません。
System.NullReferenceException:オブジェクト参照がオブジェクトのインスタンスに設定されていません
コード:
Dim Name As String = txtName.Text
Dim Email As String = txtEmail.Text
Dim Password As String = txtPassword.Text
Dim Repassword As String = txtRepassword.Text
Dim Country As String = txtCountry.Text
Dim College As String = txtCollege.Text
Dim Phone As String = txtPhone.Text
これは、txtName.text
がNULLであることを示しています。どうすれば修正できますか?
マイ制御コードはここにある:
'''<summary>
'''txtName control.
'''</summary>
'''<remarks>
'''Auto-generated field.
'''To modify move field declaration from designer file to code-behind file.
'''</remarks>
Protected WithEvents txtName As Global.System.Web.UI.WebControls.TextBox
'''<summary>
'''txtEmail control.
'''</summary>
'''<remarks>
'''Auto-generated field.
'''To modify move field declaration from designer file to code-behind file.
'''</remarks>
Protected WithEvents txtEmail As Global.System.Web.UI.WebControls.TextBox
'''<summary>
'''txtPassword control.
'''</summary>
'''<remarks>
'''Auto-generated field.
'''To modify move field declaration from designer file to code-behind file.
'''</remarks>
Protected WithEvents txtPassword As Global.System.Web.UI.WebControls.TextBox
'''<summary>
'''txtRepasword control.
'''</summary>
'''<remarks>
'''Auto-generated field.
'''To modify move field declaration from designer file to code-behind file.
'''</remarks>
Protected WithEvents txtRepassword As Global.System.Web.UI.WebControls.TextBox
'''<summary>
'''txtCountry control.
'''</summary>
'''<remarks>
'''Auto-generated field.
'''To modify move field declaration from designer file to code-behind file.
'''</remarks>
Protected WithEvents txtCountry As Global.System.Web.UI.WebControls.TextBox
'''<summary>
'''txtCollege control.
'''</summary>
'''<remarks>
'''Auto-generated field.
'''To modify move field declaration from designer file to code-behind file.
'''</remarks>
Protected WithEvents txtCollege As Global.System.Web.UI.WebControls.TextBox
'''<summary>
'''txtPhone control.
'''</summary>
'''<remarks>
'''Auto-generated field.
'''To modify move field declaration from designer file to code-behind file.
'''</remarks>
Protected WithEvents txtPhone As Global.System.Web.UI.WebControls.TextBox
をトレースし、あなたのコントロールの名前や種類を確認。 txtNameはコントロールの名前ではないか、そうでない場合はTextプロパティのコントロールタイプではないようです。 –
宣言時にtxtName値を取得することはできません。ボタンのクリックや他のイベントでキャプチャしようとする必要があります – techspider
@techspiderボタンでクリックしたときにテキストボックスの値をキャプチャしようとしましたが、同じエラーが発生しました – Ashutosh