|
-
Apr 20th, 2013, 03:18 AM
#1
Thread Starter
Junior Member
If mistake !
HTML Code:
Public Class login
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim usernam1 As String = "youssef"
Dim usernam2 As String = "Mariam"
Dim unknown As String = TextBox.Text
Dim password1 As String = "hey"
Dim password2 As String = "hi"
Dim unknownp As String = TextBox2.Text
If TextBox.Text = usernam1 Then
Label3.Text = "Correct"
ElseIf TextBox.Text = usernam2 Then
Label3.Text = "Correct"
ElseIf TextBox.Text = unknown Then
Label3.Text = "Invaild username"
End If
If TextBox2.Text = password1 Then
Label4.Text = "Correct"
ElseIf TextBox2.Text = password2 Then
Label4.Text = "Correct"
ElseIf TextBox2.Text = unknownp Then
Label4.Text = "Invalid Password"
End If
If showd() Then
Me.Close()
End If
End Sub
Private Function showd() As Boolean
If youssef() Or Mariam() Then
If MessageBox.Show("Do you want to continue?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
Calculator.Show()
End If
End If
Return True
End Function
Private Function youssef() As Boolean
If Label3.Text = "Correct" And Label4.Text = "Correct" And TextBox.Text = "youssef" And TextBox2.Text = "hey" Then
MessageBox.Show("Welcome Youssef", "Welcome", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
Return True
End Function
Private Function Mariam() As Boolean
If Label3.Text = "Correct" And Label4.Text = "Correct" And TextBox.Text = "Mariam" And TextBox2.Text = "hi" Then
MessageBox.Show("Welcome Mariam", "Welcome", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
Return True
End Function
End Class
I don't know what the **** is wrong with this part?
HTML Code:
Private Function showd() As Boolean
If youssef() Or Mariam() Then
If MessageBox.Show("Do you want to continue?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
Calculator.Show()
End If
End If
Return True
End Function
I want if function youssef or function Mariam then calculator form shows and if it's not youssef or mariam it just end the programme
-
Apr 20th, 2013, 03:22 AM
#2
Thread Starter
Junior Member
Re: If mistake !
OKay I fixed it a bit but it also doesn't work :
HTML Code:
Private Function showd() As Boolean
If youssef() Or Mariam() Then
Label5.Text = "Done"
Else : Label5.Text = "suck"
End If
I made it to be a small example but if youssef function is ok it shows on label5.text "Done" and if it doesn't it also shows "done" I want it if it is not youssef or Mariam then label5.text = "suck"
Last edited by Youssef; Apr 20th, 2013 at 03:26 AM.
-
Apr 20th, 2013, 03:36 AM
#3
Thread Starter
Junior Member
Re: If mistake !
I discovered that the problem is with the function youssef and Mariam but I don't know why? because if I make it like this:
HTML Code:
If Label3.Text = "Correct" And Label4.Text = "Correct" And TextBox.Text = "youssef" And TextBox2.Text = "hey" Then
Label5.Text = "done"
Else : Label5.Text = "suck"
End If
and it worked but if I used the function it doesn't work !
-
Apr 20th, 2013, 03:47 AM
#4
Thread Starter
Junior Member
Re: If mistake !
one more failure try:
HTML Code:
If fin() Then
Me.Close()
End If
End Sub
Private Function fin() As Boolean
If youssef() Then
Calculator.Show()
ElseIf Mariam() Then
Calculator.Show()
End If
Return True
End Function
Private Function youssef() As Boolean
If Label3.Text = "Correct" And Label4.Text = "Correct" And TextBox.Text = "youssef" And TextBox2.Text = "hey" Then
MessageBox.Show("Welcome Youssef", "Welcome", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
Return True
End Function
Private Function Mariam() As Boolean
If Label3.Text = "Correct" And Label4.Text = "Correct" And TextBox.Text = "Mariam" And TextBox2.Text = "hi" Then
MessageBox.Show("Welcome Mariam", "Welcome", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
Return True
End Function
-
Apr 20th, 2013, 03:58 AM
#5
Thread Starter
Junior Member
Re: If mistake !
Okay Last try and it worked:
HTML Code:
If youssef() OrElse Mariam() Then
Me.Close()
End If
End Sub
Private Function youssefs() As Boolean
If youssef() Then
Calculator.Show()
End If
Return True
End Function
Private Function youssef() As Boolean
If Label3.Text = "Correct" And Label4.Text = "Correct" And TextBox.Text = "youssef" And TextBox2.Text = "hey" Then
Calculator.Show()
End If
Return True
End Function
Private Function Mariam() As Boolean
If Label3.Text = "Correct" And Label4.Text = "Correct" And TextBox.Text = "Mariam" And TextBox2.Text = "hi" Then
Calculator.Show()
End If
Return True
End Function
but I want the messagebox.show(etc etc) at the function youssef and Mariam
-
Apr 20th, 2013, 05:38 AM
#6
Re: If mistake !
Going back to your original code:
Your youssef funtion tests if it is youssef who is logging in.
It should return True if it is youssef.
It should return False if it isn't youssef.
The logic should be something like:
PseudoCode
IF all labels = "Correct" and it is youssef THEN
Show welcome message
RETURN TRUE
ELSE
RETURN FALSE
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|