+ Reply to Thread
Results 1 to 4 of 4

Code for login id to be unique

  1. #1
    Registered User
    Join Date
    02-03-2012
    Location
    Bangalore,India
    MS-Off Ver
    Excel 2007
    Posts
    13

    Code for login id to be unique

    Hi
    i am quite new to vba. i am trying to create a login/register screen. My motive is to

    a) Encrypt the password in the Password textfield in the userform but when it is stored in the excel sheet, it should be decrypted
    b)here is a piece of code . Whatever Login ID i give, it always says "Userlogin is already present. Please use some other login"

    Private Sub rgcmdbtsv_Click()
    Dim insertrow As Integer
    Dim i As Integer, Message As Integer
    'Dim wspwd As Sheets
    'Set wspwd = Worksheets("Passwords")
    insertrow = Worksheets("Passwords").UsedRange.Rows.Count + 1
    If insertrow > 1 Then
    For i = 2 To insertrow - 1
    If StrComp(rgtxtbxlid.Value, Worksheets("Passwords").Cells(insertrow, 2).Value, vbTextCompare) = 0 Then
    Message = MsgBox("Userlogin is already present. Please use some other login", vbOK, "Try again")
    rgtxtbxlid.Value = ""
    Exit For
    ElseIf rgtxtbxnm.Value = "" Then
    Message = MsgBox("Name cannot be null", vbOK, "Try Again")
    Exit For

    ElseIf rgtxtbxlid.Value = "" Then
    Message = MsgBox("Login ID cannot be null", vbOK, "Try Again")
    Exit For

    ElseIf rgtxtbxpwd.Value = "" Then
    Message = MsgBox("Password cannot be null", vbOK, "Try Again")
    Exit For

    Else
    Worksheets("Passwords").Cells(insertrow, 1) = rgtxtbxnm.Value
    Worksheets("Passwords").Cells(insertrow, 2) = rgtxtbxlid.Value
    Worksheets("Passwords").Cells(insertrow, 3) = rgtxtbxpwd.Value
    End If

    Next
    Else
    End If

    End Sub
    Please Login or Register  to view this content.
    Last edited by Gourav; 03-09-2014 at 03:52 PM.

  2. #2
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Code for login id to be unique

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  3. #3
    Registered User
    Join Date
    02-03-2012
    Location
    Bangalore,India
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Code for login id to be unique

    modified my code but still having the same problem with login id. even if i put duplicate login id, no error is thrown

    Private Sub rgcmdbtsv_Click()
    Dim insertrow As Integer
    Dim i As Integer, Message As Integer
    'Dim wspwd As Sheets
    'Set wspwd = Worksheets("Passwords")
    insertrow = Worksheets("Passwords").UsedRange.Rows.Count + 1
    'If insertrow > 1 Then
    ' For i = 2 To insertrow - 1

    If rgtxtbxnm.Value = "" Or IsNull(rgtxtbxnm.Value) Then
    Message = MsgBox("Name cannot be null", vbOK, "Try Again")
    rgtxtbxnm.SetFocus
    Exit Sub
    End If

    If rgtxtbxlid.Value = "" Or IsNull(rgtxtbxlid.Value) Then
    Message = MsgBox("Login ID cannot be null", vbOK, "Try Again")
    rgtxtbxlid.SetFocus
    Exit Sub
    End If

    If rgtxtbxpwd.Value = "" Or IsNull(rgtxtbxpwd.Value) Then
    Message = MsgBox("Password cannot be null", vbOK, "Try Again")
    rgtxtbxpwd.SetFocus
    Exit Sub
    End If

    For i = 2 To insertrow - 1
    Please Login or Register  to view this content.
    If StrComp(rgtxtbxlid.Value, Worksheets("Passwords").Cells(i, 2).Value, vbTextCompare) = 0 Then

    'VarLid = Worksheets("Passwords").Vlookup(rgtxtbxlid.Value,
    Message = MsgBox("Userlogin is already present. Please use some other login", vbOK, "Try again")
    rgtxtbxlid.Value = ""
    rgtxtbxlid.SetFocus
    Exit Sub

    Else
    Worksheets("Passwords").Cells(insertrow, 1) = rgtxtbxnm.Value
    Worksheets("Passwords").Cells(insertrow, 2) = rgtxtbxlid.Value
    Worksheets("Passwords").Cells(insertrow, 3) = rgtxtbxpwd.Value
    rgtxtbxnm.Value = ""
    rgtxtbxlid.Value = ""
    rgtxtbxpwd.Value = ""
    Exit For
    End If
    Next
    'Next
    'Else
    'End If

    'insertrow = i + 1

    End Sub

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2406 Win 11 Home 64 Bit
    Posts
    23,951

    Re: Code for login id to be unique

    Click on edit post. Highlight your code. Now click on the hashtag (#) just above in formatting section. The words [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] will surround your highlighted code. Save your post. Do this everytime you post VBA code. Our rules are important here and should not be disregarded.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Web page - login code
    By keen2xl in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-10-2014, 12:59 AM
  2. Replies: 0
    Last Post: 03-18-2013, 02:58 PM
  3. Login to a website via vba code
    By danitouffaha in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-09-2012, 10:06 PM
  4. Help! Need VBA code for login FtpServer
    By triniti in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-29-2011, 01:56 PM
  5. UserName login code
    By Bruise in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-10-2006, 12:10 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1