home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_tools / manythng / password.frm < prev    next >
Text File  |  1994-03-17  |  6KB  |  207 lines

  1. VERSION 2.00
  2. Begin Form Password 
  3.    Caption         =   "Form1"
  4.    ClientHeight    =   2355
  5.    ClientLeft      =   3180
  6.    ClientTop       =   2580
  7.    ClientWidth     =   4785
  8.    Height          =   2760
  9.    Left            =   3120
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   2355
  12.    ScaleWidth      =   4785
  13.    Top             =   2235
  14.    Width           =   4905
  15.    Begin CommandButton Cancel 
  16.       Caption         =   "Cancel"
  17.       FontBold        =   -1  'True
  18.       FontItalic      =   0   'False
  19.       FontName        =   "Times New Roman"
  20.       FontSize        =   12
  21.       FontStrikethru  =   0   'False
  22.       FontUnderline   =   0   'False
  23.       Height          =   465
  24.       Left            =   2790
  25.       TabIndex        =   5
  26.       Top             =   1665
  27.       Width           =   1185
  28.    End
  29.    Begin CommandButton OK 
  30.       Caption         =   "OK"
  31.       FontBold        =   -1  'True
  32.       FontItalic      =   0   'False
  33.       FontName        =   "Times New Roman"
  34.       FontSize        =   12
  35.       FontStrikethru  =   0   'False
  36.       FontUnderline   =   0   'False
  37.       Height          =   465
  38.       Left            =   1170
  39.       TabIndex        =   4
  40.       Top             =   1665
  41.       Width           =   1005
  42.    End
  43.    Begin TextBox NewPassword2 
  44.       FontBold        =   -1  'True
  45.       FontItalic      =   0   'False
  46.       FontName        =   "Times New Roman"
  47.       FontSize        =   12
  48.       FontStrikethru  =   0   'False
  49.       FontUnderline   =   0   'False
  50.       Height          =   420
  51.       Left            =   2655
  52.       PasswordChar    =   "*"
  53.       TabIndex        =   3
  54.       Text            =   "Text3"
  55.       Top             =   1035
  56.       Width           =   2040
  57.    End
  58.    Begin TextBox NewPassword 
  59.       FontBold        =   -1  'True
  60.       FontItalic      =   0   'False
  61.       FontName        =   "Times New Roman"
  62.       FontSize        =   12
  63.       FontStrikethru  =   0   'False
  64.       FontUnderline   =   0   'False
  65.       Height          =   420
  66.       Left            =   2655
  67.       PasswordChar    =   "*"
  68.       TabIndex        =   2
  69.       Text            =   "Text2"
  70.       Top             =   630
  71.       Width           =   2040
  72.    End
  73.    Begin TextBox OldPassword 
  74.       FontBold        =   -1  'True
  75.       FontItalic      =   0   'False
  76.       FontName        =   "Times New Roman"
  77.       FontSize        =   12
  78.       FontStrikethru  =   0   'False
  79.       FontUnderline   =   0   'False
  80.       Height          =   420
  81.       Left            =   2655
  82.       PasswordChar    =   "*"
  83.       TabIndex        =   1
  84.       Text            =   "Text1"
  85.       Top             =   225
  86.       Width           =   2040
  87.    End
  88.    Begin Label Label3 
  89.       Caption         =   "New Password Retyped:"
  90.       FontBold        =   -1  'True
  91.       FontItalic      =   0   'False
  92.       FontName        =   "Times New Roman"
  93.       FontSize        =   12
  94.       FontStrikethru  =   0   'False
  95.       FontUnderline   =   0   'False
  96.       Height          =   375
  97.       Left            =   135
  98.       TabIndex        =   7
  99.       Top             =   1035
  100.       Width           =   2670
  101.    End
  102.    Begin Label Label2 
  103.       Caption         =   "New Password:"
  104.       FontBold        =   -1  'True
  105.       FontItalic      =   0   'False
  106.       FontName        =   "Times New Roman"
  107.       FontSize        =   12
  108.       FontStrikethru  =   0   'False
  109.       FontUnderline   =   0   'False
  110.       Height          =   285
  111.       Left            =   180
  112.       TabIndex        =   6
  113.       Top             =   675
  114.       Width           =   2760
  115.    End
  116.    Begin Label OldPasswordLabel 
  117.       Caption         =   "Old Password:"
  118.       FontBold        =   -1  'True
  119.       FontItalic      =   0   'False
  120.       FontName        =   "Times New Roman"
  121.       FontSize        =   12
  122.       FontStrikethru  =   0   'False
  123.       FontUnderline   =   0   'False
  124.       Height          =   285
  125.       Left            =   180
  126.       TabIndex        =   0
  127.       Top             =   270
  128.       Width           =   2715
  129.    End
  130. End
  131. Option Explicit
  132.  
  133. Sub Cancel_Click ()
  134.  
  135.   Hide 'make form invisible
  136.  
  137. End Sub
  138.  
  139. Sub Form_Load ()
  140.  
  141.     'clear fields
  142.     OldPassword.Text = ""
  143.     NewPassword.Text = ""
  144.     NewPassword2.Text = ""
  145.  
  146.     'see if existing password
  147.     If Passwd = "" Then
  148.       OldPassword.Enabled = False
  149.       OldPasswordLabel.Enabled = False
  150.     End If
  151.  
  152. End Sub
  153.  
  154. Sub OK_Click ()
  155.  
  156.   Dim temp As String
  157.  
  158.   temp = OldPassword.Text
  159.   OldPassword.Text = UnCase(temp)
  160.   temp = NewPassword.Text
  161.   NewPassword.Text = UnCase(temp)
  162.   temp = NewPassword2.Text
  163.   NewPassword2.Text = UnCase(temp)
  164.  
  165.   '1st verify old password
  166.   If Passwd <> OldPassword.Text Then
  167.     MsgBox "Old password incorrect", 48, "Change Password"
  168.     Exit Sub
  169.   End If
  170.  
  171.   'double check new password
  172.   If NewPassword.Text <> NewPassword2.Text Then
  173.     MsgBox "New password failed retype verify", 48, "Change Password"
  174.     Exit Sub
  175.   End If
  176.  
  177.   If Len(NewPassword.Text) > NUMCHARS Then
  178.     MsgBox "New password too long" + Chr$(10) + "Maximum length " + Str$(NUMCHARS) + " chars", 48, "Change Password"
  179.     Exit Sub
  180.   End If
  181.  
  182.   Passwd = NewPassword.Text
  183.   Unload Password 'unload form from memory
  184.  
  185. End Sub
  186.  
  187. Function UnCase (Text As String) As String
  188.  
  189.   Dim i As Integer, j As Integer, k As Integer, l As Integer
  190.   Dim outstr As String
  191.  
  192.   'gets the unshifted ascii code for characters by
  193.   'converting each to a virtual key code and then
  194.   'converting back to ascii
  195.   outstr = ""
  196.   k = Len(Text)
  197.   For i = 1 To k
  198.     j = VkKeyScan(Asc(Mid$(Text, i, 1))) Mod 256 ' convert ascii to virtual key code
  199.     l = MapVirtualKey(j, 2) ' convert virtual key code to ascii
  200.     outstr = outstr + Chr$(l)
  201.   Next i
  202.  
  203.   UnCase = outstr
  204.  
  205. End Function
  206.  
  207.