登录表单连接到Excel电子表格 [英] Login Form connecting to Excel spreadsheet

查看:81
本文介绍了登录表单连接到Excel电子表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个名为login的表单,该表单允许两个用户登录但查看不同的表单.表格1-仅允许您查看数据库.表格二允许用户编辑我连接到表格的Excel电子表格(保存,删除,添加记录);但该代码不允许第二个用户查看第二个表单.

I''ve created a a form called login which allows two users to log in but view different forms. Form 1 - allows you to view the database only. Form two allows the user to edit the Excel spreadsheet which I connected to the form (save, delete, add a record); but the code is not allowing the second user to view the second form.

If txtUsername.Text = " " And txtPassword.Text = " " Then
            MsgBox("Please enter your username and Password.", MsgBoxStyle.Information, "Login")
        Else

            If txtUsername.Text = "" Then
                MsgBox("Please enter your Username", MsgBoxStyle.Information, "Login")
            Else

                If txtPassword.Text = "" Then
                    MsgBox("Please enter your Password", MsgBoxStyle.Information, "Login")
                Else

                    If txtUsername.Text = "admin" And txtPassword.Text = "admin0123" Then
                        Me.Hide()
                        Form2.Show() 'Form 2 is in view only format
                    Else
                        If txtUsername.Text = "stacey" And txtPassword.Text = "stacey01" Then
                            Me.Hide()
                            Form3.Show()




我添加,删除,保存的编码根本不起作用.

请帮助...




and my coding for the add, delete, save does not want to work at all.

Please help...

推荐答案

尝试逐行调试代码(F8),您将了解为何无法访问Form2的原因. 我建议您像这样更改代码(对您来说更易读):
Try to debug your code line by line (F8) and you''ll see why the Form2 is not accessible.
I suggest you to change code like this (it will be more readible for you):
If txtUsername.Text = String.Empty Then
    MsgBox("Please enter your Username", MsgBoxStyle.Information, "Login")
    Exit Sub
End If
 
If txtPassword.Text = String.Empty Then
    MsgBox("Please enter your Password", MsgBoxStyle.Information, "Login")
    Exit Sub
End If

If txtUsername.Text = "admin" And txtPassword.Text = "admin0123" Then
    Me.Hide()
    Form2.Show() 'Form 2 is in view only format
End If

If txtUsername.Text = "stacey" And txtPassword.Text = "stacey01" Then
    Me.Hide()
    Form3.Show()
End If



提示:在程序内部(在过程内部)存储用户名(登录名)和密码不是一个好习惯.



Hint: Storing the names of users (logins) and passwords inside the program (inside the procedure) is not good practice.


这篇关于登录表单连接到Excel电子表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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