' ===================== ' Functions and Subroutines ' ===================== Function GenerateUniqueID() Dim uniqueID, isUnique isUnique = False Do While Not isUnique uniqueID = Int((9999 - 1000 + 1) * Rnd + 1000) ' Generate a random 4-digit number If Not IDExists(uniqueID) Then isUnique = True End If Loop GenerateUniqueID = uniqueID End Function Function IDExists(checkID) ' ... [same as before] End Function Function SearchUser(id) ' ... [same as before] End Function Sub SaveUser(id, name, code) ' ... [same as before] End Sub ' ===================== ' Initialization ' ===================== Sub Initialize() ' ... [same as before] End Sub ' ===================== ' Main Logic ' ===================== Initialize() Dim username, password username = InputBox("Enter Username:") password = InputBox("Enter Password:", "Password", "*") If username <> "Security" Or password <> "admin" Then MsgBox "Invalid username or password!", vbExclamation, "Access Denied" WScript.Quit End If Dim choice choice = MsgBox("O ID já existe?", vbYesNo + vbQuestion, "Confirmação") If choice = vbYes Then Dim id id = InputBox("Enter User ID:") MsgBox SearchUser(id) ElseIf choice = vbNo Then Dim newID, newName, newCode newID = GenerateUniqueID() newName = InputBox("Enter User Name:") newCode = InputBox("Enter User Code:") Dim saveChoice saveChoice = MsgBox("Deseja salvar o novo usuário com ID: " & newID & "?", vbYesNo + vbQuestion, "Salvar Usuário") If saveChoice = vbYes Then SaveUser newID, newName, newCode MsgBox "User saved successfully with ID: " & newID End If End If