标题:[求助]关于VB.NET登录窗口的实现
取消只看楼主
bianyuan
Rank: 1
等 级:新手上路
帖 子:21
专家分:0
注 册:2006-11-3
 问题点数:0 回复次数:0 
[求助]关于VB.NET登录窗口的实现

我做个登陆窗口,可有一个问题解决不了,望高人指点,不胜感激啊
原码如下:

Public Class frmlogin
Inherits System.Windows.Forms.Form
Public bresult As Boolean = False
Public userid As String = ""
Public username As String = ""
Public userpwd As String = ""

Private Sub txbpwd_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txbpwd.KeyPress
If e.KeyChar = Microsoft.VisualBasic.ChrW(13) And userid <> "" Then
Me.btnsubmit_Click(Nothing, Nothing)
End If
End Sub

Private Sub txbuserid_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txbuserid.KeyPress
If e.KeyChar = Microsoft.VisualBasic.ChrW(13) Then
Me.txbpwd.Focus()
End If
End Sub

Private Sub txbuserid_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txbuserid.LostFocus
Dim db As DataBase = New DataBase
Dim dv As DataView = db.RunDelOrInsSQL(" select 密码,用户名 from 用户表 where 用户号='" + Me.txbuserid.Text.Trim() + "'")
If dv.Count = 0 Then
Me.txbuserid.Text = ""
Me.txbpwd.Text = ""
Me.txbname.Text = ""
Else
userid = Me.txbuserid.Text.Trim()
Me.userpwd = dv.Item(0)("密码")
Me.txbname.Text = dv.Item(0)("用户名")
End If
db.Dispose()
End Sub

Private Sub btnsubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnsubmit.Click
If Me.userpwd.Trim() = Me.txbpwd.Text.Trim() And userpwd <> "" Then
bresult = True
username = Me.txbname.Text.Trim()
Me.Close()
Else
bresult = False
MessageBox.Show("请确认你的用户名或密码是否正确!!")

End If
End Sub

Private Sub btnclear_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnclear.Click
Me.Close()
Application.Exit()
End Sub

End Class
=================================================================================================================================
==================================================================================================================================
====================================================================================
可是执行时却有如下错误:
未处理的“System.NullReferenceException”类型的异常出现在 财务管理.exe 中。

其他信息: 未将对象引用设置到对象的实例。
-----------------------------------------------
---------------------------------------------
--------------------------------------
Private Sub txbuserid_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txbuserid.LostFocus
Dim db As DataBase = New DataBase
Dim dv As DataView = db.RunDelOrInsSQL(" select 密码,用户名 from 用户表 where 用户号='" + Me.txbuserid.Text.Trim() + "'")
If dv.Count = 0 Then
Me.txbuserid.Text = ""
Me.txbpwd.Text = ""
Me.txbname.Text = ""
Else
userid = Me.txbuserid.Text.Trim()
Me.userpwd = dv.Item(0)("密码")
Me.txbname.Text = dv.Item(0)("用户名")
End If
db.Dispose()
End Sub
其中划横线的地方背景颜色为黄(调试时).
=================================================================================================================
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
==================================================================================================================
上述问题该怎么处理啊,是什么原因导致的?谢谢,请教高手.

搜索更多相关主题的帖子: NET 窗口 登录 
2007-05-10 13:52



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-138206-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.048017 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved