假如管理员对应开放的菜单名称都在一个字符串StrMenus里(这个事先保存在你数据库里的),主窗体为 MainF,则代码如下:
For Each V In MainF.Controls
Vname = UCase(V.Name)
If UCase(TypeName(V)) = "MENU" Then
If InStr(StrMenus, Vname) > 0 Then
V.Enabled = True
Else
V.Enabled = False
End If
End If
Next
vb2008做的: userpri = ComboBox1.Text.ToString.Trim
username = TextBox1.Text.ToString.Trim
password = TextBox2.Text.ToString.Trim
Dim n As Integer = judgeVege()
If (username = "" And password = "") Then
MessageBox.Show("用户名密码不能为空!!")
Else
If (userpri = "操作员") Then
If n >= 1 Then
Form1.Show()
Else
MessageBox.Show("用户名或密码错误")
End If
ElseIf (userpri = "管理员") Then
If n >= 1 Then
Manager.Show()
Else
MessageBox.Show("用户名或密码错误")
End If
End If
End If
TextBox1.Text = ""
TextBox2.Text = ""