表格和密码 [英] Forms and Passwords

查看:66
本文介绍了表格和密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个脚本,它会一直打开相同的表单

而不是只有一个实例。我还需要一个有密码的

表单的帮助。我在哪里输入实际的

密码?我可以为多个用户使用数据库吗?


打开多个密码表单实例而不是一个:


Public Class Splash

继承System.Windows.Forms.Form


#Region" Windows窗体设计器生成的代码


Public Sub New()

MyBase.New()


' 'Windows窗体需要此调用

设计器。

InitializeComponent()


''在
InitializeComponent()调用


End Sub


''表格覆盖dispose来清理组件

list。

受保护的重载覆盖Sub Dispose(ByVal

作为布尔值处理)

如果处置则

如果不是(组件什么都没有)那么

components.Dispose()

结束如果

结束如果

MyBase.Dispose(disposing)

End Sub


''Windows窗体设计师要求

私有组件作为系统.ComponentModel.IContainer


''注意:

Windows窗体设计师需要以下程序

''它可以用来修改g Windows窗体设计器。

''不要使用代码编辑器修改它。

Friend WithEvents SplashIMG As

System.Windows.Forms .PictureBox

Friend WithEvents SplashTimer As

System.Windows.Forms.Timer

< System.Diagnostics.DebuggerStepThrough()>私有

Sub InitializeComponent()

Me.components = New

System.ComponentModel.Container()

Dim资源As System.Resources.ResourceManager

=新的System.Resources.ResourceManager(GetType(Splash))

Me.SplashIMG = New System.Windows.Forms.PictureBox

()

Me.SplashTimer = New System.Windows.Forms.Timer

(Me.components)

Me .SuspendLayout()

''

''SplashIMG

''

Me.SplashIMG.Image = CType (resources.GetObject

(" SplashIMG.Image"),System.Drawing.Bitmap)

Me.SplashIMG.Name =" SplashIMG"

Me.SplashIMG.Size = New System.Drawing.Size(600,

300)

Me.SplashIMG.TabIndex = 0

Me.SplashIMG.TabStop = False

''

''SplashTimer

''

Me.SplashTimer .Enabled = True

Me.SplashTimer.Interval = 1000

''
''Splash

''

Me.AutoScaleBaseSize = New System.Drawing.Size(5,

13 )

Me.ClientSize = New System.Drawing.Size(600,300)

Me.Controls.AddRange(New

System.Windows .Forms.Control(){Me.SplashIMG})

Me.FormBorderStyle =

System.Windows.Forms.FormBorderStyle.None

Me .Name =" Splash"

Me.ShowInTaskbar = False

Me.StartPosition =

System.Windows.Forms.FormStartPosition.CenterScree n

Me.Text =" KS.IntraNet"

Me.ResumeLayout(False)


End Sub


#End Region

Private Sub SplashIMG_Click(ByVal sender As

System.Object,ByVal e As System.EventArgs)Handles

SplashIMG。点击


结束子


私人子Timer1_Tick(ByVal发件人为

System.Object,ByVal e As System.EventArgs)Handles

SplashTimer.Tick

Dim frmLogin As New Login()

frmLogin.Show()

End Sub


End Class


密码表格:


公共类登录

继承System.Windows.Forms.Form


#Region" Windows窗体设计器生成的代码


Public Sub New()

MyBase.New()


' 'Windows窗体需要此调用

设计器。

InitializeComponent()


''在
InitializeComponent()调用


End Sub


''表格覆盖dispose来清理组件

list。

受保护的重载覆盖Sub Dispose(ByVal

作为布尔值处理)

如果处置则

如果不是(组件什么都没有)那么

components.Dispose()

结束如果

结束如果

MyBase.Dispose(disposing)

End Sub


''Windows窗体设计师要求

私有组件作为系统.ComponentModel.IContainer


''注意:

Windows窗体设计师需要以下程序

''它可以用来修改Windows窗体设计器。

''不要使用代码编辑器修改它。

Friend WithEvents UserLbl As

System.Windows.Forms .Label

Friend WithEvents UserINP As

System.Windows.Forms.TextBox

Friend WithEvents PassINP As

系统.Windows.Forms.TextBox

Friend WithEvents PassLbl As

System.Windows.Forms.Label

Friend WithEvents LoginBTN As

System.Windows.Forms.Button

Friend WithEvents CancelBTN As

System.Windows.Forms.Button

< System.Diagnostics .DebuggerStepThrough()>私有

Sub InitializeComponent()

Me.UserLbl = New System.Windows.Forms.Label()

Me.UserINP =新系统。 Windows.Forms.TextBox()

Me.PassINP = New System.Windows.Forms.TextBox()

Me.PassLbl = New System.Windows.Forms.Label( )

Me.LoginBTN = New System.Windows.Forms.Button()

Me.CancelBTN = New System.Windows.Forms.Button()

Me.SuspendLayout()

''

''UserLbl

''

Me.UserLbl .Location = New System.Drawing.Point(0,

10)

Me.UserLbl.Name =" UserLbl"

Me。 UserLbl.Size = New System.Drawing.Size(64,16)

Me.UserLbl.TabIndex = 0

Me.UserLbl.Text =" Username:"

''

''UserINP

''

Me.UserINP.Location = New System.Drawing。点

(56,8)

Me.UserINP.Name =" UserINP"

Me.UserINP.Size = New System.Drawing .Size(1 20,20)

Me.UserINP.TabIndex = 1

Me.UserINP.Text =""

''

''PassINP

''

Me.PassINP.Location = New System.Drawing.Point

(56,32 )

Me.PassINP.Name =" PassINP"

Me.PassINP.PasswordChar =

Microsoft.VisualBasic.ChrW(42)

Me.PassINP.Size = New System.Drawing.Size(120,20)

Me.PassINP.TabIndex = 2

Me.PassINP .Text =""

Me.Validate.Equals(3224)

''

''PassLbl

''

Me.PassLbl.Location =新System.Drawing.Point(0,

34)

Me.PassLbl.Name =" PassLbl"

Me.PassLbl.Size = New System.Drawing.Size(64,16)

Me.PassLbl.TabIndex = 3

Me.PassLbl.Text ="密码:"

''

''LoginBTN

''

Me.LoginBTN.Location = New System.Drawing.Point

(16,56)

Me.LoginBTN.Name =" LoginBTN"

Me.LoginBTN.Size = New System.Drawing.Size(66,24)

Me.LoginBTN.TabIndex = 4

Me.LoginBTN.Text ="登录"

''

''CancelBTN
''

Me.CancelBTN.Location = New System.Drawing.Point

(96,56)

Me。 CancelBTN.Name =" CancelBTN"

Me.CancelBTN.Size = New System.Drawing.Size(66,

24)

Me .CancelBTN.TabIndex = 5

Me.CancelBTN.Text ="取消>

''

''登录

''

Me.AutoScaleBaseSize = New System.Drawing.Size(5,

13)

Me.ClientSize =新系统.Drawing.Size(186,88)

Me.Controls.AddRange(New

System.Windows.Forms.Control(){Me.CancelBTN,

Me.LoginBTN,Me.UserINP,Me.PassINP,Me.PassLbl,

Me.UserLbl})

Me.FormBorderStyle =

System.Windows.Forms.FormBorde rStyle.FixedToolWind ow

Me.Name =" Login"

Me.StartPosition =

System.Windows.Forms.FormStartPosition.CenterScree n

Me.Text ="网络登录

Me.ResumeLayout(假)


结束子


#End Region


Private Sub Login_Load(ByVal sender As System.Object,

ByVal e As System.EventArgs)处理MyBase.Load


End Sub


Private Sub Login_Click(ByVal发送者为

System.Object,ByVal e As System.EventArgs)句柄

UserLbl点击


结束子


私有子取消BTN_Click(ByVal发送者为

System.Object,ByVal e As System.EventArgs)句柄

CancelBTN.Click

结束

结束子


私有子PassINP_TextChanged (ByVal发送者为

System.Object,ByVal e As System.EventArgs)句柄

PassINP.TextChanged


结束Sub < br $> b $ b结束班


感谢提前帮助


Joshua Kendall

解决方案

*" Joshua Kendall" <乔**** @ goartic.com> scripsit:

我有一个脚本,它不断打开相同的表单
而不是只有一个实例。我还需要一个有密码的
表单的帮助。我在哪里放实际的密码?我可以为多个用户使用数据库吗?




这取决于应用程序的类型。如果用户能够从

数据库中读取密码,则将密码存储在

数据库中是没有意义的。如果你提供更多关于你的申请目的的b $ b信息,也许更容易找到一个好的解决方案。


-

Herfried K. Wagner

MVP·VB Classic,VB.NET

< http://www.mvps.org/dotnet>


它有点像程序的网络接口。只有

一个用户可以在一个

时间使用该信息登录,并且数据库将被隐藏和加密。

---- - 原创讯息-----
*Joshua Kendall <乔**** @ goartic.com> scripsit:

我有一个脚本,它继续打开相同的
表单,而不是只打开一个实例。我还需要一个有密码的
表单的帮助。我在哪里放实际的密码?我可以为多个用户使用数据库吗?
这取决于应用程序的类型。如果用户能够从数据库中读取
,则在数据库中存储



密码是没有意义的。如果
你提供更多关于你的申请目的的信息,也许更容易找到一个好的解决方案。

-
Herfried K. Wagner
MVP· VB Classic,VB.NET
< http://www.mvps.org/dotnet>



I'将密码存储在配置文件/注册表或数据库中

加密。如果你将它们存储在数据库中,那么你可以在程序打开时调用一个可以验证密码的完全gimped

帐户,

但不要存储您的密码以明文形式显示,除非您是10000000%

确定不想要的眼睛永远不会看到它。


如果您只想要一个班级的实例一次打开(窗体,

不是应用程序),然后按顺序制作一个Singleton模式....这里是一个很好的链接

实现
http:// www。 ondotnet.com/pub/a/dotnet...singleton.html


就多个用户的数据库而言......可能是简短的回答。大多数

每个商业数据库都支持多用户,虽然桌面数据库像B / B
一样,不能很好地处理多个用户。 >
大多数情况。


就密码形式而言,您需要什么帮助?以上将

向您展示如何只确保一个实例。就表单本身而言,将一个

文本框拖到您的表单上(您提到表单,所以我假设这是一个Windows

程序,而不是一个Web程序)然后设置

文本框的PasswordChar属性,该文本框将密码保存为某些字符,如*。
http://msdn.microsoft.com/library/de .. .dchartopic.asp

然后,当用户输入密码时,他们会看到*****。而不是

mypassword

有许多加密文本的好例子,这里有一个很好的链接
http://www.dotnetsmart.com/showpost.aspx?PostID=255 。所以你需要做的就是

在第一次通过时将密码提交给数据库加密。

每个请求数据库获取密码并解密它。在您的BusinessLogic组件中本地执行
,以便您通过网络发送加密数据

,除非您确定没有人在嗅探它

(即便如此,我仍然建议将它包裹在一个强大的加密包裹下来。

算法)。


如果你有,请告诉我任何具体的问题,虽然我可以帮助

你...或者如果我不清楚什么。


干杯,


Bill

" Joshua Kendall" <乔**** @ goartic.com>在留言中写道

news:00 **************************** @ phx.gbl ... < blockquote class =post_quotes>我有一个脚本,它不断打开相同的表单
而不是只有一个实例。我还需要一个有密码的
表单的帮助。我在哪里放实际的密码?我可以为多个用户使用数据库吗?

打开多个密码表单实例而不是一个:

Public Class Splash
继承System.Windows.Forms.Form

#Region" Windows窗体设计器生成的代码

Public Sub New()
MyBase.New()

''Windows窗体需要此调用 Designer。
InitializeComponent()
''在<< InitializeComponent()调用后添加任何初始化

End Sub

>''表格覆盖处理以清理组件
列表。
受保护的重载覆盖子处理(ByVal
处理为布尔值)
如果处置则
如果不是(组件是什么都没有)然后
components.Dispose()
结束如果
结束如果
MyBase.Dispose(处置)
结束子

''Windows窗体设计器要求
私有组件As System.ComponentModel.IContainer

''注意:
Windows窗体设计器需要以下步骤
''可以修改使用Windows窗体设计器。
''不要使用代码编辑器修改它。
朋友WithEvents SplashIMG As
System.Windows.Forms.PictureBox
Friend WithEvents SplashTimer As br /> System.Windows.Forms.Timer
< System.Diagnostics.DebuggerStepThrough()>私有
Sub InitializeComponent()
Me.components = New
System.ComponentModel.Container()
Dim resources As System.Resources.ResourceManager
= New System.Resources .ResourceManager(GetType(Splash))
Me.SplashIMG = New System.Windows.Forms.PictureBox
()
Me.SplashTimer = New System.Windows.Forms.Timer
(Me.components)
Me.SuspendLayout()
''
''SplashIMG
''
Me.SplashIMG.Image = CType(resources.GetObject
(" SplashIMG.Image"),System.Drawing.Bitmap)
Me.SplashIMG.Name =" SplashIMG"
Me.SplashIMG.Size = New System.Drawing.Size(600,
300)
Me.SplashIMG.TabIndex = 0
Me.SplashIMG.TabStop = False
''
''SplashTimer
'' Me.SplashTimer.Enabled = True
Me.SplashTimer.Interval = 1000 <飞溅
''
Me.AutoScaleBaseSize =新的System.Drawing.Size(5,
13)
Me.ClientSize = New System.Drawing.Size(600,300)
Me.Controls.AddRange(New
System.Windows.Forms.Control(){Me.SplashIMG})
Me.FormBorderStyle =
System.Windows.Forms.FormBorderStyle.None
Me.Name =" Splash"
Me.ShowInTaskbar = False
Me.StartPosition =
System.Windows.Forms。 FormStartPosition.CenterScree n
Me.Text =" KS.IntraNet"
Me.ResumeLayout(False)

End Sub

#End Region <私有Sub SplashIMG_Click(ByVal发送者为
System.Object,ByVal e As System.EventArgs)处理
SplashIMG.Click

End Sub

私有子Timer1_Tick(ByVal发送者为
System.Object,ByVal e As System.EventArgs)处理
SplashTimer.Tick
Dim frmLogin为新登录()
frmLogin.Show()
End Sub

结束课程

密码表格:
公共类登录
继承System.Windows.Forms.Form

#Region" Windows窗体设计器生成的代码

Public Sub New()
MyBase.New()

''Windows窗体需要此调用 Designer。
InitializeComponent()
''在<< InitializeComponent()调用后添加任何初始化

End Sub

>''表格覆盖处理以清理组件
列表。
受保护的重载覆盖子处理(ByVal
处理为布尔值)
如果处置则
如果不是(组件是什么都没有)然后
components.Dispose()
结束如果
结束如果
MyBase.Dispose(处置)
结束子

''Windows窗体设计器要求
私有组件As System.ComponentModel.IContainer

''注意:
Windows窗体设计器需要以下步骤
''可以修改使用Windows窗体设计器。
''不要使用代码编辑器修改它。
朋友WithEvents UserLbl As
System.Windows.Forms.Label
Friend WithEvents UserINP As
System.Windows.Forms.TextBox
Friend WithEvents PassINP As
System.Windows.Forms.TextBox
Friend WithEvents PassLbl As
System.Windows.Forms.Label Friend WithEvents LoginBTN As
System.Windows.Forms.Button
Friend WithEvents CancelBTN As
System.Windows.Forms.Button
< System.Diagnostics.DebuggerStepThrough()>私有
Sub InitializeComponent()
Me.UserLbl = New System.Windows.Forms.Label()
Me.UserINP = New System.Windows.Forms.TextBox()
我.PassINP = New System.Windows.Forms.TextBox()
Me.PassLbl = New System.Windows.Forms.Label()
Me.LoginBTN = New System.Windows.Forms.Button()< br.> Me.CancelBTN = New System.Windows.Forms.Button()
Me.SuspendLayout()
''
''UserLbl
''
我.UserLbl.Location = New System.Drawing.Point(0,
10)
Me.UserLbl.Name =" UserLbl"
Me.UserLbl.Size = New System.Drawing.Size (64,16)
Me.UserLbl.TabIndex = 0
Me.UserLbl.Text ="用户名:"
''
''UserINP
' '
Me.UserINP.Location = New System.Drawing.Point
(56,8)
Me.UserINP.Name =" UserINP"
Me.UserINP.Size = New System.Drawing.Size(120,20)
Me.UserINP.TabIndex = 1
Me.UserINP.Text =""
''
''PassINP
''
Me.PassINP.Location = New System.Drawing.Point
(56,32)
Me.PassINP.Name =" PassINP"
Me.PassINP.PasswordChar =
Microsoft.VisualBasic.ChrW(42)
Me.PassINP.Size = New System.Drawing.Size(120,20)
Me.PassINP .TabIndex = 2
Me.PassINP.Text =""
Me.Validate.Equals(3224)
''
''PassLbl
''< br.> Me.PassLbl.Location = New System.Drawing.Point(0,
34)
Me.PassLbl.Name =" PassLbl"
Me.PassLbl.Size = New System .Drawing.Size(64,16)
Me.PassLbl.TabIndex = 3
Me.PassLbl.Text ="密码:"
''
''LoginB TN
''
Me.LoginBTN.Location = New System.Drawing.Point
(16,56)
Me.LoginBTN.Name =" LoginBTN"
Me.LoginBTN.Size = New System.Drawing.Size(66,24)
Me.LoginBTN.TabIndex = 4
Me.LoginBTN.Text =" Login"
''
''CancelBTN
''
Me.CancelBTN.Location = New System.Drawing.Point
(96,56)
Me.CancelBTN.Name =" CancelBTN"
Me.CancelBTN.Size = New System.Drawing.Size(66,
24)
Me.CancelBTN.TabIndex = 5
Me.CancelBTN.Text =" Cancel"
''
''登录
''
Me.AutoScaleBaseSize = New System.Drawing.Size(5,
13)
Me.ClientSize =新的System.Drawing.Size(186,88)
Me.Controls.AddRange(新的
System.Windows.Forms.Control(){Me.CancelBTN,
Me.LoginBTN,我。 ü serINP,Me.PassINP,Me.PassLbl,
Me.UserLbl})
Me.FormBorderStyle =
System.Windows.Forms.FormBorderStyle.FixedToolWind ow
Me.Name =" ;登录"
Me.StartPosition =
System.Windows.Forms.FormStartPosition.CenterScree n
Me.Text ="网络登录
Me.ResumeLayout(假)

结束子

#End Region
私人Sub Login_Load(ByVal发送者为系统.Object,
ByVal e As System.EventArgs)处理MyBase.Load

End Sub

私有Sub Login_Click(ByVal发送者为
System.Object ,ByVal e As System.EventArgs)处理
UserLbl.Click

End Sub

私人Sub CancelBTN_Click(ByVal发送者为
System.Object,ByVal e作为System.EventArgs)处理
CancelBTN.Click
结束


私有Sub PassINP_TextChanged(ByVal发送者为
System.Object,ByVal e作为System.EventArgs)处理
PassINP.TextChanged

End Sub
End Class

感谢提前帮助
Joshua Kendall



I have a script in which it keeps opening the same form
instead of only one instance. I also need help with a
form that has a password. Where do I put the actual
password? can I use a database for multiple users?

opens multiple instances of password form instead of one:

Public Class Splash
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

''This call is required by the Windows Form
Designer.
InitializeComponent()

''Add any initialization after the
InitializeComponent() call

End Sub

''Form overrides dispose to clean up the component
list.
Protected Overloads Overrides Sub Dispose(ByVal
disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

''Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

''NOTE: The following procedure is required by the
Windows Form Designer
''It can be modified using the Windows Form Designer.
''Do not modify it using the code editor.
Friend WithEvents SplashIMG As
System.Windows.Forms.PictureBox
Friend WithEvents SplashTimer As
System.Windows.Forms.Timer
<System.Diagnostics.DebuggerStepThrough()> Private
Sub InitializeComponent()
Me.components = New
System.ComponentModel.Container()
Dim resources As System.Resources.ResourceManager
= New System.Resources.ResourceManager(GetType(Splash))
Me.SplashIMG = New System.Windows.Forms.PictureBox
()
Me.SplashTimer = New System.Windows.Forms.Timer
(Me.components)
Me.SuspendLayout()
''
''SplashIMG
''
Me.SplashIMG.Image = CType(resources.GetObject
("SplashIMG.Image"), System.Drawing.Bitmap)
Me.SplashIMG.Name = "SplashIMG"
Me.SplashIMG.Size = New System.Drawing.Size(600,
300)
Me.SplashIMG.TabIndex = 0
Me.SplashIMG.TabStop = False
''
''SplashTimer
''
Me.SplashTimer.Enabled = True
Me.SplashTimer.Interval = 1000
''
''Splash
''
Me.AutoScaleBaseSize = New System.Drawing.Size(5,
13)
Me.ClientSize = New System.Drawing.Size(600, 300)
Me.Controls.AddRange(New
System.Windows.Forms.Control() {Me.SplashIMG})
Me.FormBorderStyle =
System.Windows.Forms.FormBorderStyle.None
Me.Name = "Splash"
Me.ShowInTaskbar = False
Me.StartPosition =
System.Windows.Forms.FormStartPosition.CenterScree n
Me.Text = "KS.IntraNet"
Me.ResumeLayout(False)

End Sub

#End Region

Private Sub SplashIMG_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
SplashIMG.Click

End Sub

Private Sub Timer1_Tick(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
SplashTimer.Tick
Dim frmLogin As New Login()
frmLogin.Show()
End Sub

End Class

Password Form:

Public Class Login
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

''This call is required by the Windows Form
Designer.
InitializeComponent()

''Add any initialization after the
InitializeComponent() call

End Sub

''Form overrides dispose to clean up the component
list.
Protected Overloads Overrides Sub Dispose(ByVal
disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

''Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

''NOTE: The following procedure is required by the
Windows Form Designer
''It can be modified using the Windows Form Designer.
''Do not modify it using the code editor.
Friend WithEvents UserLbl As
System.Windows.Forms.Label
Friend WithEvents UserINP As
System.Windows.Forms.TextBox
Friend WithEvents PassINP As
System.Windows.Forms.TextBox
Friend WithEvents PassLbl As
System.Windows.Forms.Label
Friend WithEvents LoginBTN As
System.Windows.Forms.Button
Friend WithEvents CancelBTN As
System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private
Sub InitializeComponent()
Me.UserLbl = New System.Windows.Forms.Label()
Me.UserINP = New System.Windows.Forms.TextBox()
Me.PassINP = New System.Windows.Forms.TextBox()
Me.PassLbl = New System.Windows.Forms.Label()
Me.LoginBTN = New System.Windows.Forms.Button()
Me.CancelBTN = New System.Windows.Forms.Button()
Me.SuspendLayout()
''
''UserLbl
''
Me.UserLbl.Location = New System.Drawing.Point(0,
10)
Me.UserLbl.Name = "UserLbl"
Me.UserLbl.Size = New System.Drawing.Size(64, 16)
Me.UserLbl.TabIndex = 0
Me.UserLbl.Text = "Username:"
''
''UserINP
''
Me.UserINP.Location = New System.Drawing.Point
(56, 8)
Me.UserINP.Name = "UserINP"
Me.UserINP.Size = New System.Drawing.Size(120, 20)
Me.UserINP.TabIndex = 1
Me.UserINP.Text = ""
''
''PassINP
''
Me.PassINP.Location = New System.Drawing.Point
(56, 32)
Me.PassINP.Name = "PassINP"
Me.PassINP.PasswordChar =
Microsoft.VisualBasic.ChrW(42)
Me.PassINP.Size = New System.Drawing.Size(120, 20)
Me.PassINP.TabIndex = 2
Me.PassINP.Text = ""
Me.Validate.Equals(3224)
''
''PassLbl
''
Me.PassLbl.Location = New System.Drawing.Point(0,
34)
Me.PassLbl.Name = "PassLbl"
Me.PassLbl.Size = New System.Drawing.Size(64, 16)
Me.PassLbl.TabIndex = 3
Me.PassLbl.Text = "Password:"
''
''LoginBTN
''
Me.LoginBTN.Location = New System.Drawing.Point
(16, 56)
Me.LoginBTN.Name = "LoginBTN"
Me.LoginBTN.Size = New System.Drawing.Size(66, 24)
Me.LoginBTN.TabIndex = 4
Me.LoginBTN.Text = "Login"
''
''CancelBTN
''
Me.CancelBTN.Location = New System.Drawing.Point
(96, 56)
Me.CancelBTN.Name = "CancelBTN"
Me.CancelBTN.Size = New System.Drawing.Size(66,
24)
Me.CancelBTN.TabIndex = 5
Me.CancelBTN.Text = "Cancel"
''
''Login
''
Me.AutoScaleBaseSize = New System.Drawing.Size(5,
13)
Me.ClientSize = New System.Drawing.Size(186, 88)
Me.Controls.AddRange(New
System.Windows.Forms.Control() {Me.CancelBTN,
Me.LoginBTN, Me.UserINP, Me.PassINP, Me.PassLbl,
Me.UserLbl})
Me.FormBorderStyle =
System.Windows.Forms.FormBorderStyle.FixedToolWind ow
Me.Name = "Login"
Me.StartPosition =
System.Windows.Forms.FormStartPosition.CenterScree n
Me.Text = " Network Login"
Me.ResumeLayout(False)

End Sub

#End Region

Private Sub Login_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

Private Sub Login_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
UserLbl.Click

End Sub

Private Sub CancelBTN_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
CancelBTN.Click
End
End Sub

Private Sub PassINP_TextChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
PassINP.TextChanged

End Sub
End Class

Thanks for the help in advance

Joshua Kendall

解决方案

* "Joshua Kendall" <jo****@goartic.com> scripsit:

I have a script in which it keeps opening the same form
instead of only one instance. I also need help with a
form that has a password. Where do I put the actual
password? can I use a database for multiple users?



This depends on the type of the application. Storing a password in a
database doesn''t make sense if the user is able to read it from the
database. Maybe it''s easier to find a good solution if you provide more
information on the purpose of your application.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>


It''s kind of like a network interface for a program. Only
one user can be logged in with that information at one
time and a database would be hidden and encrypted.

-----Original Message-----
* "Joshua Kendall" <jo****@goartic.com> scripsit:

I have a script in which it keeps opening the same form instead of only one instance. I also need help with a
form that has a password. Where do I put the actual
password? can I use a database for multiple users?
This depends on the type of the application. Storing a


password in adatabase doesn''t make sense if the user is able to read it from thedatabase. Maybe it''s easier to find a good solution if you provide moreinformation on the purpose of your application.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
.



I''d store the passwords in a config file/registry or in a database
encrypted. If you store them in the DB, then make a totally gimped out
account that you call when the program opens that can verify the password,
but don''t store your passwords in clear text unless you are 10000000%
certain that unwanted eyes will never see it.

If you want only one instance of your class to ever be open at once (form,
not app), then a Singleton pattern is made to order.... here''s a good link
on the implementation
http://www.ondotnet.com/pub/a/dotnet...singleton.html

As far as database for multiple users...the short answer is probably . Most
every commercial Database supports multi-users, although desktop databases
like Access don''t do a very good job of handling more than a few users in
most cases.

As far as form with a Password, what do you need help with? The above will
show you how to ensure only one instance. As far as the form itself, drag a
textbox onto your form (you mention Forms so I''m assuming this is a Windows
program, not a web program) and then set the PasswordChar property of the
textbox which will hold the password to some character like "*".
http://msdn.microsoft.com/library/de...dchartopic.asp
Then, when a user types in a password, they will see "*****" instead of
"mypassword"
there are many good examples of encrypting text, here''s one good link
http://www.dotnetsmart.com/showpost.aspx?PostID=255 . So all you need to do
is encrypt the password when you submit it to the DB the first time through.
Each request tot he DB gets the cypher text and decrypts it. Do this
locally in your BusinessLogic component so that you send encrypted data
over your network, unless you are 100000 sure that no one is sniffiing it
(and even then, I''d still recommend sending it wrapped under a strong crypto
algorithm).

Let me know if you are having any specific problems though that I can help
you with..or If I was unclear about anything.

Cheers,

Bill
"Joshua Kendall" <jo****@goartic.com> wrote in message
news:00****************************@phx.gbl...

I have a script in which it keeps opening the same form
instead of only one instance. I also need help with a
form that has a password. Where do I put the actual
password? can I use a database for multiple users?

opens multiple instances of password form instead of one:

Public Class Splash
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

''This call is required by the Windows Form
Designer.
InitializeComponent()

''Add any initialization after the
InitializeComponent() call

End Sub

''Form overrides dispose to clean up the component
list.
Protected Overloads Overrides Sub Dispose(ByVal
disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

''Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

''NOTE: The following procedure is required by the
Windows Form Designer
''It can be modified using the Windows Form Designer.
''Do not modify it using the code editor.
Friend WithEvents SplashIMG As
System.Windows.Forms.PictureBox
Friend WithEvents SplashTimer As
System.Windows.Forms.Timer
<System.Diagnostics.DebuggerStepThrough()> Private
Sub InitializeComponent()
Me.components = New
System.ComponentModel.Container()
Dim resources As System.Resources.ResourceManager
= New System.Resources.ResourceManager(GetType(Splash))
Me.SplashIMG = New System.Windows.Forms.PictureBox
()
Me.SplashTimer = New System.Windows.Forms.Timer
(Me.components)
Me.SuspendLayout()
''
''SplashIMG
''
Me.SplashIMG.Image = CType(resources.GetObject
("SplashIMG.Image"), System.Drawing.Bitmap)
Me.SplashIMG.Name = "SplashIMG"
Me.SplashIMG.Size = New System.Drawing.Size(600,
300)
Me.SplashIMG.TabIndex = 0
Me.SplashIMG.TabStop = False
''
''SplashTimer
''
Me.SplashTimer.Enabled = True
Me.SplashTimer.Interval = 1000
''
''Splash
''
Me.AutoScaleBaseSize = New System.Drawing.Size(5,
13)
Me.ClientSize = New System.Drawing.Size(600, 300)
Me.Controls.AddRange(New
System.Windows.Forms.Control() {Me.SplashIMG})
Me.FormBorderStyle =
System.Windows.Forms.FormBorderStyle.None
Me.Name = "Splash"
Me.ShowInTaskbar = False
Me.StartPosition =
System.Windows.Forms.FormStartPosition.CenterScree n
Me.Text = "KS.IntraNet"
Me.ResumeLayout(False)

End Sub

#End Region

Private Sub SplashIMG_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
SplashIMG.Click

End Sub

Private Sub Timer1_Tick(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
SplashTimer.Tick
Dim frmLogin As New Login()
frmLogin.Show()
End Sub

End Class

Password Form:

Public Class Login
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

''This call is required by the Windows Form
Designer.
InitializeComponent()

''Add any initialization after the
InitializeComponent() call

End Sub

''Form overrides dispose to clean up the component
list.
Protected Overloads Overrides Sub Dispose(ByVal
disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

''Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

''NOTE: The following procedure is required by the
Windows Form Designer
''It can be modified using the Windows Form Designer.
''Do not modify it using the code editor.
Friend WithEvents UserLbl As
System.Windows.Forms.Label
Friend WithEvents UserINP As
System.Windows.Forms.TextBox
Friend WithEvents PassINP As
System.Windows.Forms.TextBox
Friend WithEvents PassLbl As
System.Windows.Forms.Label
Friend WithEvents LoginBTN As
System.Windows.Forms.Button
Friend WithEvents CancelBTN As
System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private
Sub InitializeComponent()
Me.UserLbl = New System.Windows.Forms.Label()
Me.UserINP = New System.Windows.Forms.TextBox()
Me.PassINP = New System.Windows.Forms.TextBox()
Me.PassLbl = New System.Windows.Forms.Label()
Me.LoginBTN = New System.Windows.Forms.Button()
Me.CancelBTN = New System.Windows.Forms.Button()
Me.SuspendLayout()
''
''UserLbl
''
Me.UserLbl.Location = New System.Drawing.Point(0,
10)
Me.UserLbl.Name = "UserLbl"
Me.UserLbl.Size = New System.Drawing.Size(64, 16)
Me.UserLbl.TabIndex = 0
Me.UserLbl.Text = "Username:"
''
''UserINP
''
Me.UserINP.Location = New System.Drawing.Point
(56, 8)
Me.UserINP.Name = "UserINP"
Me.UserINP.Size = New System.Drawing.Size(120, 20)
Me.UserINP.TabIndex = 1
Me.UserINP.Text = ""
''
''PassINP
''
Me.PassINP.Location = New System.Drawing.Point
(56, 32)
Me.PassINP.Name = "PassINP"
Me.PassINP.PasswordChar =
Microsoft.VisualBasic.ChrW(42)
Me.PassINP.Size = New System.Drawing.Size(120, 20)
Me.PassINP.TabIndex = 2
Me.PassINP.Text = ""
Me.Validate.Equals(3224)
''
''PassLbl
''
Me.PassLbl.Location = New System.Drawing.Point(0,
34)
Me.PassLbl.Name = "PassLbl"
Me.PassLbl.Size = New System.Drawing.Size(64, 16)
Me.PassLbl.TabIndex = 3
Me.PassLbl.Text = "Password:"
''
''LoginBTN
''
Me.LoginBTN.Location = New System.Drawing.Point
(16, 56)
Me.LoginBTN.Name = "LoginBTN"
Me.LoginBTN.Size = New System.Drawing.Size(66, 24)
Me.LoginBTN.TabIndex = 4
Me.LoginBTN.Text = "Login"
''
''CancelBTN
''
Me.CancelBTN.Location = New System.Drawing.Point
(96, 56)
Me.CancelBTN.Name = "CancelBTN"
Me.CancelBTN.Size = New System.Drawing.Size(66,
24)
Me.CancelBTN.TabIndex = 5
Me.CancelBTN.Text = "Cancel"
''
''Login
''
Me.AutoScaleBaseSize = New System.Drawing.Size(5,
13)
Me.ClientSize = New System.Drawing.Size(186, 88)
Me.Controls.AddRange(New
System.Windows.Forms.Control() {Me.CancelBTN,
Me.LoginBTN, Me.UserINP, Me.PassINP, Me.PassLbl,
Me.UserLbl})
Me.FormBorderStyle =
System.Windows.Forms.FormBorderStyle.FixedToolWind ow
Me.Name = "Login"
Me.StartPosition =
System.Windows.Forms.FormStartPosition.CenterScree n
Me.Text = " Network Login"
Me.ResumeLayout(False)

End Sub

#End Region

Private Sub Login_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

Private Sub Login_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
UserLbl.Click

End Sub

Private Sub CancelBTN_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
CancelBTN.Click
End
End Sub

Private Sub PassINP_TextChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
PassINP.TextChanged

End Sub
End Class

Thanks for the help in advance

Joshua Kendall



这篇关于表格和密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆