Consulting

Results 1 to 3 of 3

Thread: Solved: verifying password in txtbox

  1. #1
    VBAX Contributor
    Joined
    Feb 2008
    Posts
    193
    Location

    Solved: verifying password in txtbox

    Hello,

    i've a problem with a code for verifying a password.

    In the textbox i've
    [VBA]
    Private Sub CommandButton1_Click()
    If password.pword.Value = "cosy" Then
    pword.Value = ""
    password.Hide
    Else
    MsgBox "verkeerd wachtwoord"
    pword.Value = ""
    End
    End If
    End Sub
    [/VBA]

    the macro is:

    [VBA]
    Sub Start()
    If Rows("205:312").Hidden = True Then
    openen
    Else
    Verwerken
    End If
    End Sub
    Sub Verwerken()
    ActiveSheet.Unprotect "zima"
    Application.ScreenUpdating = False
    Dim Cell As Range
    For Each Cell In Range("I5:GH84")
    If UCase(Cell.Value) = "RES" _
    And IsNumeric(Cell.Offset(200).Value) _
    And Not Cell.Offset(200).Value = vbNullString Then
    'do nothing
    Else
    Cell.Value = Cell.Offset(200).Value
    End If
    Next
    doen
    Sheets("wk 27 tm 52").Select
    Application.ScreenUpdating = True
    Rows("205:312").Hidden = True
    ActiveSheet.Protect password:="zima", DrawingObjects:=False, Contents:=True, Scenarios:= _
    True, AllowFormattingCells:=True

    End Sub
    Sub openen()
    Worksheets("wk 27 tm 52").Activate
    password.Show
    ' If password.pword.Value = "cosy" Then
    ActiveSheet.Unprotect "zima"
    Rows("205:312").Hidden = False
    ' password.Hide
    ActiveSheet.Protect password:="zima"
    ' End If
    End Sub
    [/VBA]

    if a user stops the textbox (clicking x in the right upper corner) the macro start anyway.
    how can i prevent this?

    Thx,

    Ger

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Add this to the form

    [vba]

    Private Sub UserForm_QueryClose(cancel As Integer, closemode As Integer)

    If closemode = vbFormControlMenu Then

    MsgBox "Use the Exit button to quit"
    cancel = True
    End If
    End Sub[/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Contributor
    Joined
    Feb 2008
    Posts
    193
    Location
    XLD,

    Thx a lot.

    Ger

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •