home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / screen / password.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1994-11-28  |  5.2 KB  |  183 lines

  1. VERSION 2.00
  2. Begin Form frmPassword 
  3.    BorderStyle     =   3  'Fixed Double
  4.    Caption         =   "Change Password"
  5.    ClientHeight    =   2085
  6.    ClientLeft      =   2490
  7.    ClientTop       =   2790
  8.    ClientWidth     =   4695
  9.    Height          =   2490
  10.    Left            =   2430
  11.    LinkTopic       =   "Form1"
  12.    MaxButton       =   0   'False
  13.    MinButton       =   0   'False
  14.    ScaleHeight     =   2085
  15.    ScaleWidth      =   4695
  16.    Top             =   2445
  17.    Width           =   4815
  18.    Begin CommandButton cmdCancel 
  19.       Cancel          =   -1  'True
  20.       Caption         =   "Cancel"
  21.       Height          =   375
  22.       Left            =   3360
  23.       TabIndex        =   7
  24.       Top             =   1560
  25.       Width           =   1215
  26.    End
  27.    Begin CommandButton cmdOK 
  28.       Caption         =   "OK"
  29.       Default         =   -1  'True
  30.       Height          =   375
  31.       Left            =   120
  32.       TabIndex        =   6
  33.       Top             =   1560
  34.       Width           =   1215
  35.    End
  36.    Begin TextBox txtRetype 
  37.       Enabled         =   0   'False
  38.       Height          =   315
  39.       Left            =   2160
  40.       MaxLength       =   20
  41.       PasswordChar    =   "*"
  42.       TabIndex        =   5
  43.       Top             =   1080
  44.       Width           =   2415
  45.    End
  46.    Begin TextBox txtNew 
  47.       Enabled         =   0   'False
  48.       Height          =   315
  49.       Left            =   2160
  50.       MaxLength       =   20
  51.       PasswordChar    =   "*"
  52.       TabIndex        =   4
  53.       Top             =   600
  54.       Width           =   2415
  55.    End
  56.    Begin TextBox txtOld 
  57.       Height          =   315
  58.       Left            =   2160
  59.       MaxLength       =   20
  60.       PasswordChar    =   "*"
  61.       TabIndex        =   3
  62.       Top             =   120
  63.       Width           =   2415
  64.    End
  65.    Begin Label lblRetype 
  66.       Caption         =   "Retype New Password:"
  67.       Enabled         =   0   'False
  68.       Height          =   195
  69.       Left            =   120
  70.       TabIndex        =   2
  71.       Top             =   1140
  72.       Width           =   1995
  73.    End
  74.    Begin Label lblNew 
  75.       Caption         =   "New Password"
  76.       Enabled         =   0   'False
  77.       Height          =   195
  78.       Left            =   120
  79.       TabIndex        =   1
  80.       Top             =   660
  81.       Width           =   1695
  82.    End
  83.    Begin Label lblOld 
  84.       Caption         =   "Old Password:"
  85.       Height          =   195
  86.       Left            =   120
  87.       TabIndex        =   0
  88.       Top             =   180
  89.       Width           =   1635
  90.    End
  91. Option Explicit
  92. Sub cmdCancel_Click ()
  93.     Unload Me
  94. End Sub
  95. Sub cmdOK_Click ()
  96. Dim putback As String
  97.     '
  98.     ' Validate the change of password
  99.     '
  100.     If Password <> CalcPassnum((txtOld.Text)) Then
  101.         MsgBox "The value for Old Password is not correct." & Chr$(13) & Chr$(13) & "Check your screen saver password, and then try again.", 16, "Change Password"
  102.         txtNew.Text = ""
  103.         txtRetype.Text = ""
  104.         txtOld.SetFocus
  105.         Exit Sub
  106.     End If
  107.     If txtNew.Text <> txtRetype.Text Then
  108.         MsgBox "The Values for New Password and Retype New" & Chr$(13) & "Password do not match." & Chr$(13) & Chr$(13) & "Try again.", 16, "Change Password"
  109.         txtNew.Text = ""
  110.         txtRetype.Text = ""
  111.         txtNew.SetFocus
  112.         Exit Sub
  113.     End If
  114.     '
  115.     ' Write the password to the ini file
  116.     '
  117.     Password = CalcPassnum((txtNew.Text))
  118.     If Password <> OldPassword Then
  119.         putback = Format$(Password)
  120.         Call PutIni(iniName, iniSection, "Password", putback)
  121.         OldPassword = Password
  122.     End If
  123.     Unload Me
  124. End Sub
  125. Sub Form_Load ()
  126.     '
  127.     ' Enable the text boxes and lables as appropriate
  128.     '
  129.     If Password > 0 Then
  130.         txtOld.Enabled = True
  131.         lblOld.Enabled = True
  132.         txtNew.Enabled = False
  133.         lblNew.Enabled = False
  134.         txtRetype.Enabled = False
  135.         lblRetype.Enabled = False
  136.     Else
  137.         txtOld.Enabled = False
  138.         lblOld.Enabled = False
  139.         txtNew.Enabled = True
  140.         lblNew.Enabled = True
  141.         txtRetype.Enabled = True
  142.         lblRetype.Enabled = True
  143.     End If
  144.     CentreForm Me
  145. End Sub
  146. Sub txtNew_GotFocus ()
  147.     txtNew.SelStart = 0
  148.     txtNew.SelLength = Len(txtNew.Text)
  149. End Sub
  150. Sub txtNew_LostFocus ()
  151.     txtNew.Text = UCase$(txtNew.Text)
  152. End Sub
  153. Sub txtOld_Change ()
  154.     '
  155.     ' Enable the text boxes and lables as appropriate
  156.     '
  157.     If Len(txtOld) > 0 Then
  158.         txtNew.Enabled = True
  159.         lblNew.Enabled = True
  160.         txtRetype.Enabled = True
  161.         lblRetype.Enabled = True
  162.     Else
  163.         txtNew.Enabled = False
  164.         lblNew.Enabled = False
  165.         txtRetype.Enabled = False
  166.         lblRetype.Enabled = False
  167.     End If
  168. End Sub
  169. Sub txtOld_GotFocus ()
  170.     txtOld.SelStart = 0
  171.     txtOld.SelLength = Len(txtOld.Text)
  172. End Sub
  173. Sub txtOld_LostFocus ()
  174.     txtOld.Text = UCase$(txtOld.Text)
  175. End Sub
  176. Sub txtRetype_GotFocus ()
  177.     txtRetype.SelStart = 0
  178.     txtRetype.SelLength = Len(txtRetype.Text)
  179. End Sub
  180. Sub txtRetype_LostFocus ()
  181.     txtRetype.Text = UCase$(txtRetype.Text)
  182. End Sub
  183.