home *** CD-ROM | disk | FTP | other *** search
/ Master 95 #1 / MASTER95_1.iso / microsof / vbasic4 / vb4-6.cab / newug.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-07-26  |  3.5 KB  |  124 lines

  1. VERSION 4.00
  2. Begin VB.Form frmNewUserGroup 
  3.    BorderStyle     =   3  'Fixed Double
  4.    ClientHeight    =   1935
  5.    ClientLeft      =   3645
  6.    ClientTop       =   3525
  7.    ClientWidth     =   3480
  8.    Height          =   2340
  9.    HelpContextID   =   2016137
  10.    Icon            =   "NEWUG.frx":0000
  11.    Left            =   3585
  12.    LinkTopic       =   "Form1"
  13.    LockControls    =   -1  'True
  14.    MaxButton       =   0   'False
  15.    MinButton       =   0   'False
  16.    ScaleHeight     =   1935
  17.    ScaleWidth      =   3480
  18.    Top             =   3180
  19.    Width           =   3600
  20.    Begin VB.CommandButton cmdCancel 
  21.       Cancel          =   -1  'True
  22.       Caption         =   "&Cancel"
  23.       Default         =   -1  'True
  24.       Height          =   375
  25.       Left            =   1800
  26.       TabIndex        =   5
  27.       Top             =   1440
  28.       Width           =   1455
  29.    End
  30.    Begin VB.CommandButton cmdOK 
  31.       Caption         =   "&OK"
  32.       Enabled         =   0   'False
  33.       Height          =   375
  34.       Left            =   240
  35.       TabIndex        =   4
  36.       Top             =   1440
  37.       Width           =   1455
  38.    End
  39.    Begin VB.TextBox txtPID 
  40.       Height          =   285
  41.       Left            =   120
  42.       MaxLength       =   20
  43.       TabIndex        =   3
  44.       Top             =   960
  45.       Width           =   3255
  46.    End
  47.    Begin VB.TextBox txtName 
  48.       Height          =   285
  49.       Left            =   120
  50.       TabIndex        =   2
  51.       Top             =   360
  52.       Width           =   3255
  53.    End
  54.    Begin VB.Label lblLabels 
  55.       AutoSize        =   -1  'True
  56.       Caption         =   "PID:"
  57.       Height          =   195
  58.       Index           =   1
  59.       Left            =   120
  60.       TabIndex        =   1
  61.       Top             =   720
  62.       Width           =   315
  63.    End
  64.    Begin VB.Label lblLabels 
  65.       AutoSize        =   -1  'True
  66.       Caption         =   "Name:"
  67.       Height          =   195
  68.       Index           =   0
  69.       Left            =   120
  70.       TabIndex        =   0
  71.       Top             =   120
  72.       Width           =   465
  73.    End
  74. Attribute VB_Name = "frmNewUserGroup"
  75. Attribute VB_Creatable = False
  76. Attribute VB_Exposed = False
  77. Option Explicit
  78. Private Sub cmdCancel_Click()
  79.   Unload Me
  80. End Sub
  81. Private Sub cmdOK_Click()
  82.   On Error GoTo OKErr
  83.   Dim sTmp As String
  84.   Dim usr As User
  85.   Dim grp As Group
  86.   If Len(txtPID) < 4 Then
  87.     Beep
  88.     MsgBox "PID must be between 4 and 20 characters!", 48
  89.     Exit Sub
  90.   End If
  91.   If Me.Caption = "New User" Then
  92.     Set usr = gwsMainWS.CreateUser(txtName.Text, txtPID.Text)
  93.     gwsMainWS.Users.Append usr
  94.     gwsMainWS.Groups.Refresh
  95.     frmGroupsUsers.lstUsers.AddItem txtName.Text
  96.     frmGroupsUsers.lstGroupsUsers.AddItem txtName.Text
  97.     'add the new user to the Users group by default
  98.     On Error Resume Next  'just in case the users group is gone
  99.     gwsMainWS.Groups("Users").Users.Append usr
  100.     gwsMainWS.Users(txtName.Text).Groups.Refresh
  101.   Else
  102.     Set grp = gwsMainWS.CreateGroup(txtName.Text, txtPID.Text)
  103.     gwsMainWS.Groups.Append grp
  104.     gwsMainWS.Users.Refresh
  105.     frmGroupsUsers.lstGroups.AddItem txtName.Text
  106.     frmGroupsUsers.lstUsersGroups.AddItem txtName.Text
  107.   End If
  108.   Unload Me
  109.   Exit Sub
  110. OKErr:
  111.   ShowError
  112.   Exit Sub
  113. End Sub
  114. Private Sub Form_Load()
  115.   CenterMe Me, gnMDIFORM
  116. End Sub
  117. Private Sub txtName_Change()
  118.   If Len(txtName.Text) > 0 Then
  119.     cmdOK.Enabled = True
  120.   Else
  121.     cmdOK.Enabled = False
  122.   End If
  123. End Sub
  124.