Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 265
Default problems with a form and a cancel button

I have a form with: 1 accept button(commandbutton1),1 cancel
button(commandbutton1),1 user textbox(textbox1) And a pasword
textbox(textbox2)

I attached my code:

Private Sub CommandButton1_Click()
a = TextBox1
b = TextBox2
If (b = "marcos" & a = "aaaaa") Then d = MsgBox("Contraseña Inválida",
vbOKOnly, "Verifica la contraseña") Else Programador
End Sub

Private Sub CommandButton2_Click()
UserForm1.Close
End Sub

Private Sub UserForm_Initialize()
TextBox1.PasswordChar = "*"
End Sub

I have 2 problems:
1)I don't know how to tell vb to close the form (Private Sub
CommandButton2_Click()) whenb the cancel button is clicked
2) why it's not working right the "If (b = "marcos" & a = "aaaaa")", I know
it's not working because I could activate the programador macro without
writing the b=textbox2, (writing just the pasword works but I have 5
different users with five different paswords)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default problems with a form and a cancel button

Try the code like this:

Private Sub CommandButton1_Click()
a = TextBox1
b = TextBox2
If b = "marcos" And a = "aaaaa" Then
MsgBox "Contraseña Inválida", vbOKOnly, "Verifica la contraseña"
Else
Call Programador
End If
End Sub

Private Sub CommandButton2_Click()
Unload UserForm1
End Sub

Private Sub UserForm_Initialize()
TextBox1.PasswordChar = "*"
End Sub

This works for me but I am not sure that the order of the if statement is
the right way around (CommandButton1_Click). My Spanish is not great but it
looks like you are checking the password and if it matches what is in your
test then showing a message box saying invalid password otherwise running the
macro.

Hope this helps
Rowan

"filo666" wrote:

I have a form with: 1 accept button(commandbutton1),1 cancel
button(commandbutton1),1 user textbox(textbox1) And a pasword
textbox(textbox2)

I attached my code:

Private Sub CommandButton1_Click()
a = TextBox1
b = TextBox2
If (b = "marcos" & a = "aaaaa") Then d = MsgBox("Contraseña Inválida",
vbOKOnly, "Verifica la contraseña") Else Programador
End Sub

Private Sub CommandButton2_Click()
UserForm1.Close
End Sub

Private Sub UserForm_Initialize()
TextBox1.PasswordChar = "*"
End Sub

I have 2 problems:
1)I don't know how to tell vb to close the form (Private Sub
CommandButton2_Click()) whenb the cancel button is clicked
2) why it's not working right the "If (b = "marcos" & a = "aaaaa")", I know
it's not working because I could activate the programador macro without
writing the b=textbox2, (writing just the pasword works but I have 5
different users with five different paswords)

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
message box without ok or cancel button Subash Excel Discussion (Misc queries) 1 October 18th 05 10:38 AM
InputBox - cancel button Greg Billinge Excel Programming 4 October 11th 04 06:45 PM
Cancel button IamHaxer Excel Programming 3 June 24th 04 05:19 PM
Cancel Button Matt Excel Programming 3 February 3rd 04 11:23 PM
Input Box Cancel Button rickylee Excel Programming 2 January 6th 04 11:43 PM


All times are GMT +1. The time now is 03:48 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"