'
当然要用数据库(这样做的才更专业)
我给你写个简单的例子吧:
本程序共有两个窗体:form1,form2(如下所附图片)
	
		
			
form1这个窗体上有这样几个控件:text1.text(用户名),text2(密码),三个commandbutton,还有一个最重要的是Data控件(数据库连接控件)
代码如下:
Private Sub Command1_Click()
If Text1.Text = "" Or Text2.Text = "" Then
MsgBox "用户名或密码不能为空!", 1, "注意"
Exit Sub
End If
'下面这句使用select语句(SQL)指定data1的记录源
Data1.RecordSource = "select * from user where name=" & Trim(Text1.Text)
If Not Data1.Recordset.EOF Then
If Data1.Recordset.Fields("password") = Trim(Text2.Text) Then
MsgBox "验证成功!", 1, "成功"
End If
Else
MsgBox "你的密码或帐号错误!", 1, "注意"
Exit Sub
End If
End Sub
Private Sub Command3_Click()
    Form1.Hide
    Form2.Show
End Sub
Private Sub Form_Load()
    If Right(App.Path, 1) <> "\" Then
       '指定数据库的地址
       Data1.DatabaseName = App.Path & "\information.mdb"
      Else
       Data1.DatabaseName = App.Path & "information.mdb"
    End If
End Sub
form2这个窗体的控件如下图:
代码如下:
Private Sub Command1_Click()
    If Text1.Text = "" Then
       MsgBox "用户名称不能为空!", 1, "注意"
       Exit Sub
    End If
    If Text2.Text <> Text3.Text Then
       MsgBox "两次输入的密码不一致!", 1, "注意"
       Text2.Text = ""
       Text3.Text = ""
       Exit Sub
    End If
    Form1.Data1.RecordSource = "select * from user where name=" & Trim(Text1.Text)
    If Form1.Data1.Recordset.EOF Then
       Form1.Data1.Recordset.AddNew
       Form1.Data1.Recordset.Fields("name") = Trim(Text1.Text)
       Form1.Data1.Recordset.Fields("password") = Trim(Text1.Text)
       Form1.Data1.Recordset.Fields("other") = Trim(Text1.Text)
    Else
       MsgBox "该用户名已经被人注册!", 1, "注意"
       Exit Sub
    End If
    MsgBox "注册成功!", 1, "成功"
    Me.Hide
End Sub
Private Sub Command2_Click()
    Form2.Hide
    Form1.Show
End Sub
另外就是需要一个数据库: information.mdb( 表名为:user 表内有三个字段:name,password,other)放在该程序所在目录



											
	    

	


