Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I want to make a form where in the user shold first write his user name
& then password .If the user name and password are currect then the next
form will be load otherwise the user can't switch to nect form.
I use two button . Next & Cancel.I next button i use the following
command.Private Sub cmdNext_Click()
If txtName.Text = sky And txtPassword.Text = 123 Then
cmdNext.Enabled = True
Form1.Hide
Form2.Show
Else
cmdNext.Enabled = False
End If
End SubIn form Load event i use
Private Sub Form_Load()cmdNext.Enabled = False
End Sub
When i run the form write currect name, password &press next button still
VB does't switch the next form.As well as there VB6 does't show any error
Please guide me how can't i do it.
Thnaks in advance.

ok, your code looks good except for one thing. the .enabled only prevents the button from being pressed so you shouldn't be able to press the next button at all. So if you can't press the next button at all then you can't trigger the cmdNext_click. Right? What you should do is remove the .enabled from both steps. Then something like this...
cmdNext_click()
If txtName.text = "sky" and txtpass.text = "123" then
form2.show
form1.hide
else
msgbox("Incorrect user info")
txtname.setfocus
endifremember, if you use literal values like sky you must enclose them in "quotes". Otherwise VB tries to find variable values, but i'm sure you knew that. Hope this helps! BTW: when switching to another form always load the next screen first and hide the screen you are leaving after. this prevents screen flickering.

Thnaks nick for your nice help.Iam sure that this code will work. Again thanks that u guide me in a good & nice way.

No problem, i too hate when people act like jerks and give no help. Let us know if it doesn't work out, we'll work on it some more!

Again thanks ..bundle of thnaks nick. The code is working properly .U have solved my big problem .Iam so much happy & thankful for your kind co-operation. Again 1000000 times thanks
With best regards.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |