|
-
Nov 18th, 1999, 01:28 PM
#1
Thread Starter
Addicted Member
what i want to do is use a text file with a .zan extention to store users in, thats no problem. but when i want to delete a user i get all users deleted. here is the code I'm using...
Option Explicit
Private Sub cboUser_KeyPress(KeyAscii As_ Integer)
'don't allow the user to type in the
' combo
cboUser.Text = ""
End Sub
Private Sub cboUser_KeyUp(KeyCode As_ Integer, Shift As Integer)
'make sure the user can't type
cboUser.Text = ""
End Sub
Private Sub DelUser()
'sub to search for user name in my txt
' file
Dim intStart As Integer, intPos As_ Integer, intResponse As Integer, intOffSet_ As Integer
Dim strFindString As String,_ strSourceString As String
'Start from the top
frmDel.txtUsers.SetFocus
frmDel.txtUsers.SelStart = 0
intOffSet = 1
intStart = frmDel.txtUsers.SelStart + 1
strFindString = frmDel.cboUser.Text
strSourceString = frmDel.txtUsers.Text
intPos = InStr(intStart + 1,_ strSourceString, strFindString)
If intPos Then
'if the string comes after the first
'line....
frmDel.txtUsers.SelStart = intPos - 1
frmDel.txtUsers.SelLength = Len_(strFindString)
frmDel.txtUsers.SelText = ""
SendKeys "{BKSP}" ' make sure there
' are no empty lines
Else
'if the string is on the first
' line....
frmDel.txtUsers.SelStart = intPos
frmDel.txtUsers.SelLength = Len_(strFindString)
frmDel.txtUsers.SelText = ""
SendKeys "{DEL}"
End If
End Sub
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdDel_Click()
If cboUser.Text = "" Then
MsgBox "Please select a user to_ remove.", , "Error"
Exit Sub
End If
Dim I As Integer
For I = 1 To 20
'check to see if the user has to
'remain
If Cn.mnuMsg(I).Caption =_ cboUser.Text Then
MsgBox "You can't delete this_ user until all there Msg's have been_ viewed", , "Error"
Exit Sub
End If
Next
If txtPass.Text = "" Then
'make sure there is a password
MsgBox "Please enter your_ password.", , "Error"
Exit Sub
End If
Dim pass As String, cPass As String
'get the user pass from the reg (eww_ secure Not)
pass = GetSetting(AppTitle, "Users",_ cboUser.Text)
cPass = txtPass.Text
'compare the pWords
If pass = cPass Then
Call DelUser
'delete the users pWord from reg
DeleteSetting AppTitle, "Users",_ cboUser.Text
'update user file
Open App.Path & "\Users.zan" For_ Output As #1
Print #1, txtUsers.Text
Close #1
Else
MsgBox "Please re-enter your_ password", , "Invalid Password"
Exit Sub
End If
End Sub
Private Sub Form_Load()
frmZoomToFromTray Me, ZoomFormOpen,_ FromCenter, False
KillX Me
'load my user file into the txtbox to
'work with
LoadComboBox App.Path & "\Users.zan",_ cboUser
End Sub
Private Sub Form_Unload(Cancel As Integer)
frmZoomToFromTray Me, ZoomFormClosed,_ FromCenter, False
End Sub
ok pasting it into this box threw it out of whack but i think i fixed all the wrapped lines. it worked fine until i tried it a minute ago. If anybody has a better way to store the Passwords fill me in. I origanly went ini but the passwords would match and my program couldn't tell even after i trimed the ini's return
thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|