Foxtable(狐表)用户栏目专家坐堂 → 未将对象引用设置到对象的实例


  共有2317人关注过本帖树形打印复制链接

主题:未将对象引用设置到对象的实例

帅哥哟,离线,有人找我吗?
yetle
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:四尾狐 帖子:858 积分:6381 威望:0 精华:0 注册:2017/2/13 9:04:00
未将对象引用设置到对象的实例  发帖心情 Post By:2018/4/14 9:31:00 [只看该作者]

Dim Parts() As String = e.Form.Text.Split("-")
Dim txb1 As WinForm.TextBox = e.Form.Controls("TextBox1")
Dim txb2 As WinForm.TextBox = e.Form.Controls("TextBox2")
Dim txb3 As WinForm.TextBox = e.Form.Controls("TextBox3")
Dim OldUserName As String
OldUserName = Parts(Parts.Length -1)

Dim dr As DataRow =DataTables("用户表").Find("用户名称='" & OldUserName & "'")
Dim dr2 As DataRow=DataTables("用户表").Find("用户名称='" & txb1.text & "'" )
If dr2("_Identify")<> dr("_Identify")Then
MessageBox.show("已存在相同用户!","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning)
Return
End If
Dim syb As WinForm.RadioButton = e.Form.Controls("RadioButton1")
Dim ymb As WinForm.RadioButton = e.Form.Controls("RadioButton2")
Dim yuga As WinForm.RadioButton = e.Form.Controls("RadioButton3")
Dim jili As WinForm.RadioButton = e.Form.Controls("RadioButton4")
If txb3.text<>txb2.text Then
MessageBox.show("密码输入不一致!","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning)
Return
End If
dr("用户名称")=txb1.text
dr("密码")=txb2.text
If syb.Checked=True Then
dr("部门")="销售部"
Else
If ymb.Checked=True Then
dr("部门")="业务部"
End If
End If
If yuga.Checked=True Then
dr("职务")="员工"
Else
If jili.Checked=True Then
dr("职务")="经理"
End If
End If
dr.Save()
If Forms("用户管理").Opened Then
usna="admin"
Else
usna=txb1.text
End If
e.Form.close()


 回到顶部
帅哥哟,离线,有人找我吗?
wyz20130512
  2楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:六尾狐 帖子:1242 积分:9380 威望:0 精华:0 注册:2013/5/12 9:22:00
  发帖心情 Post By:2018/4/14 9:41:00 [只看该作者]

要判断一下dr和dr2是否为空。

If dr IsNot Nothing Then

End If

 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106209 积分:540168 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2018/4/14 9:48:00 [只看该作者]


 回到顶部
帅哥哟,离线,有人找我吗?
yetle
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:四尾狐 帖子:858 积分:6381 威望:0 精华:0 注册:2017/2/13 9:04:00
  发帖心情 Post By:2018/4/14 9:53:00 [只看该作者]

不对


 回到顶部
帅哥哟,离线,有人找我吗?
yetle
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:四尾狐 帖子:858 积分:6381 威望:0 精华:0 注册:2017/2/13 9:04:00
  发帖心情 Post By:2018/4/14 9:58:00 [只看该作者]

加了判断,还是一样有错误提示

 回到顶部
帅哥哟,离线,有人找我吗?
wyz20130512
  6楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:六尾狐 帖子:1242 积分:9380 威望:0 精华:0 注册:2013/5/12 9:22:00
  发帖心情 Post By:2018/4/14 10:01:00 [只看该作者]

上传实例看看

 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  7楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106209 积分:540168 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2018/4/14 10:03:00 [只看该作者]

改了什么地方?还有什么错?改后的代码发上来

不要就只是说有错,这个对解决问题没有任何帮助

 回到顶部
帅哥哟,离线,有人找我吗?
yetle
  8楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:四尾狐 帖子:858 积分:6381 威望:0 精华:0 注册:2017/2/13 9:04:00
  发帖心情 Post By:2018/4/14 10:20:00 [只看该作者]

Dim Parts() As String = e.Form.Text.Split("-")
Dim txb1 As WinForm.TextBox = e.Form.Controls("TextBox1")
Dim txb2 As WinForm.TextBox = e.Form.Controls("TextBox2")
Dim txb3 As WinForm.TextBox = e.Form.Controls("TextBox3")
Dim OldUserName As String
OldUserName = Parts(Parts.Length -1)

Dim dr As DataRow =DataTables("用户表").Find("用户名称='" & OldUserName & "'")
Dim dr2 As DataRow=DataTables("用户表").Find("用户名称='" & txb1.text & "'" )

If dr2("_Identify")<> dr("_Identify")Then
MessageBox.show("已存在相同用户!","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning)
Return
End If

Dim syb As WinForm.RadioButton = e.Form.Controls("RadioButton1")
Dim ymb As WinForm.RadioButton = e.Form.Controls("RadioButton2")
Dim yuga As WinForm.RadioButton = e.Form.Controls("RadioButton3")
Dim jili As WinForm.RadioButton = e.Form.Controls("RadioButton4")

If txb3.text<>txb2.text Then
MessageBox.show("密码输入不一致!","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning)
Return
End If
 
If dr IsNot Nothing Then
dr("用户名称")=txb1.text
dr("密码")=txb2.text
End If
'If syb.Checked=True Then
'dr("部门")="销售部"
'Else
'If ymb.Checked=True Then
'dr("部门")="业务部"
'End If
'End If
'If yuga.Checked=True Then
'dr("职务")="员工"
'Else
'If jili.Checked=True Then
'dr("职务")="经理"
'End If
'End If
dr.Save()
End If


If Forms("用户管理").Opened Then
usna="admin"
Else
usna=txb1.text
End If
e.Form.close()

 

提示还是一样

[此贴子已经被作者于2018/4/14 10:20:25编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  9楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106209 积分:540168 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2018/4/14 10:39:00 [只看该作者]


图片点击可在新窗口打开查看此主题相关图片如下:1.png
图片点击可在新窗口打开查看

 回到顶部