Hi. I'll try to be as structured as possible in this question.. but this is my first post, so please be gentle
The problem: showing an extra button in a form if the administrator is logged in
The question: is it possible to retrieve information from a closed form?
What I've done:I have created a login form with the usernames in a ComboBox called
loginbox1When a user logs in, it opens a 2nd form (using the command
mainform.Show() )
The first thing my mainform does is close the loginform (using the command
loginform.Close()Then the next thing my form is supposed to do, is check whether an administrator is logged in or not
CODE
loginform.Close()
10:
If loginform.loginbox1.Text == "Administrator" Then GoTo 20
GoTo 30
20:
adminbutton.Show : MsgBox ("IT WORKS!!") ' for testing only
30:
MsgBox ("not admin") ' for testing only
Problem is that even if the username is Administrator, it seems as if it can't read that.
I've tried googling for answers with no luck.
There is of course no need to say that I am a complete beginner to VB, so I hope that even if the solution might be quite obvios, I hope you can help me out, or at least give me some hints/tips on what to google/search for.
Kenneth
(I'll also post the code of the loginform just in case it helps understanding the problem)
CODE
Public Class loginform
Dim password As String = "secretpassword"
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles login1.Click
If loginbox1.Text = "" Then MsgBox("You need to log in") : GoTo 10
If loginbox1.Text = ("Administrator") And loginbox2.Text = password Then
adminform.Show()
ElseIf loginbox1.Text = ("Administrator") And loginbox2.Text <> password Then
MsgBox("wrong password")
Else : mainform.Show()
End If
10:
End Sub
This post has been edited by wamp: 30 Nov, 2007 - 03:51 AM