-
Jan 18th, 2018, 03:49 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Please Help!! Im on a deadline and I cant figure this out!!
I have Visual Studio 2017. These are the directions I was given:
Using what you know about search arrays, implement the VerifyUsername and VerifyPassword functions. They should return true if the username or password is found in the arrUsernames or arrPasswords array, respectively.
You should get an error message using the blnLoggedIn variable. In the next lesson, you’ll be introduced to access modifiers, but for right now, just know that you need to change the Dim keyword to Friend. See what happens when you type in an incorrect username and password.
I already changed the Dim keyword to Friend. I have also done several Elseif and if statements and I still get the same error saying im missing my return statements. Im not sure if Im writing it wrong?? Can someone PLEASE HELP!!!?? I wasnt able to upload my proj but I can post it here as a Google drive link
https://drive.google.com/file/d/1_og...ew?usp=sharing
You will have to open with Visual Studio..the link has it in document form
-
Jan 18th, 2018, 04:51 PM
#2
Re: Please Help!! Im on a deadline and I cant figure this out!!
We likely don't want to see the project, and it is likely that nobody is going to want to download something. What we want to see is the relevant code for the function(s) you are using. Just press the # button to get the CODE tags, and paste the code between them. That will get the best response.
My usual boring signature: Nothing
-
Jan 18th, 2018, 06:16 PM
#3
Thread Starter
Addicted Member
Re: Please Help!! Im on a deadline and I cant figure this out!!
ok well this is Main.vb code
Code:
Module Main
Friend blnLoggedIn As Boolean
Dim arrUsernames() As String = {"Admin, Clerk, Manager"}
Dim arrPasswords() As String = {"P@ssword, pa$$word, and passw0rd"}
Sub Login(username As String, password As String)
blnLoggedIn = False
If VerifyUsername(username) And VerifyPassword(password) Then
'Find index for username
Dim userIndex As Integer
For loopIndex = 0 To arrUsernames.Length - 1
If arrUsernames(loopIndex) = username Then
userIndex = loopIndex
Exit For
End If
Next
'Check for password match
If arrPasswords(userIndex) = password Then
blnLoggedIn = True
Else
MessageBox.Show(“Incorrect password.”)
End If
End If
End Sub
Function VerifyUsername(username As String) As Boolean
End Function
Function VerifyPassword(password As String) As Boolean
End Function
This is the loginform.vb code
Code:
Public Class LoginForm
Private Sub Label1_Click(sender As Object, e As EventArgs) Handles lblUsername.Click, btnLogin.Click
If Main.blnLoggedIn Then
MessageBox.Show(“Thank you for logging in, “ & txtUsername.Text, “Logged In.”)
Me.Close()
End If
End Sub
Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click
Application.Exit()
End Sub
End Class
The instructions that were given to me are up top in my first post. Im stuck Ive tried everything!!
-
Jan 18th, 2018, 06:16 PM
#4
Re: Please Help!! Im on a deadline and I cant figure this out!!
Not to mention the hosted file is worthless to us.
-
Jan 18th, 2018, 06:31 PM
#5
Thread Starter
Addicted Member
Re: Please Help!! Im on a deadline and I cant figure this out!!
I just tried to post the codes and it says it has to be approved by a moderator before being posted???
-
Jan 18th, 2018, 06:53 PM
#6
Thread Starter
Addicted Member
Re: Please Help!! Im on a deadline and I cant figure this out!!
***Here is my Main.vb code:
Module Main
Friend blnLoggedIn As Boolean
Dim arrUsernames() As String = {"Admin, Clerk, Manager"}
Dim arrPasswords() As String = {"P@ssword, pa$$word, and passw0rd"}
Sub Login(username As String, password As String)
blnLoggedIn = False
If VerifyUsername(username) And VerifyPassword(password) Then
'Find index for username
Dim userIndex As Integer
For loopIndex = 0 To arrUsernames.Length - 1
If arrUsernames(loopIndex) = username Then
userIndex = loopIndex
Exit For
End If
Next
'Check for password match
If arrPasswords(userIndex) = password Then
blnLoggedIn = True
Else
MessageBox.Show(“Incorrect password.”)
End If
End If
End Sub
Function VerifyUsername(username As String) As Boolean
End Function
Function VerifyPassword(password As String) As Boolean
End Function
End Module
****Here is my LoginForm.vb code:
Public Class LoginForm
Private Sub Label1_Click(sender As Object, e As EventArgs) Handles lblUsername.Click, btnLogin.Click
If Main.blnLoggedIn Then
MessageBox.Show(“Thank you for logging in, “ & txtUsername.Text, “Logged In.”)
Me.Close()
End If
End Sub
Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click
Application.Exit()
End Sub
End Class
***The instructions that were given to me are up top on my first post. Ive tried everything and im stuck so i must be doing something wrong
-
Jan 18th, 2018, 09:24 PM
#7
Re: Please Help!! Im on a deadline and I cant figure this out!!
Please use appropriate formatting tags when posting code snippets:
Originally Posted by EmilyM1105
***Here is my Main.vb code:
vb.net Code:
Module Main Friend blnLoggedIn As Boolean Dim arrUsernames() As String = {"Admin, Clerk, Manager"} Dim arrPasswords() As String = {"P@ssword, pa$$word, and passw0rd"} Sub Login(username As String, password As String) blnLoggedIn = False If VerifyUsername(username) And VerifyPassword(password) Then 'Find index for username Dim userIndex As Integer For loopIndex = 0 To arrUsernames.Length - 1 If arrUsernames(loopIndex) = username Then userIndex = loopIndex Exit For End If Next 'Check for password match If arrPasswords(userIndex) = password Then blnLoggedIn = True Else MessageBox.Show(“Incorrect password.”) End If End If End Sub Function VerifyUsername(username As String) As Boolean End Function Function VerifyPassword(password As String) As Boolean End Function End Module
****Here is my LoginForm.vb code:
vb.net Code:
Public Class LoginForm Private Sub Label1_Click(sender As Object, e As EventArgs) Handles lblUsername.Click, btnLogin.Click If Main.blnLoggedIn Then MessageBox.Show(“Thank you for logging in, “ & txtUsername.Text, “Logged In.”) Me.Close() End If End Sub Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click Application.Exit() End Sub End Class
***The instructions that were given to me are up top on my first post. Ive tried everything and im stuck so i must be doing something wrong
-
Jan 18th, 2018, 09:40 PM
#8
Re: Please Help!! Im on a deadline and I cant figure this out!!
I'm not sure why you would be surprised that you would get error messages telling you that you are missing Return statements. Both VerifyUsername and VerifyPassword are declared as functions that return a Boolean and neither of them contain any code at all. If they don't contain any code then obviously they don't contain any Return statement. If you want to be able to call them for testing other code without actually implementing them then you need to at least add a Return statement and you would return either True or False based on whether you wanted to test success or failure.
-
Jan 19th, 2018, 02:09 PM
#9
Thread Starter
Addicted Member
Re: Please Help!! Im on a deadline and I cant figure this out!!
Originally Posted by jmcilhinney
I'm not sure why you would be surprised that you would get error messages telling you that you are missing Return statements. Both VerifyUsername and VerifyPassword are declared as functions that return a Boolean and neither of them contain any code at all. If they don't contain any code then obviously they don't contain any Return statement. If you want to be able to call them for testing other code without actually implementing them then you need to at least add a Return statement and you would return either True or False based on whether you wanted to test success or failure.
I know its empty. I have tried many different if statements and For loops and it keeps giving me that same error.. thats why im asking for help
-
Jan 19th, 2018, 02:27 PM
#10
Re: Please Help!! Im on a deadline and I cant figure this out!!
Why do you expect us to know what you are doing?You have not even gave any detail.
-
Jan 19th, 2018, 02:43 PM
#11
Re: Please Help!! Im on a deadline and I cant figure this out!!
Using what you know about search arrays, implement the VerifyUsername and VerifyPassword functions. They should return true if the username or password is found in the arrUsernames or arrPasswords array, respectively.
You have defined the two functions listed above, but your code to actually check the username and the password is in the Login Sub. There are other issues beyond that, but to at least point you in the right direction, I will give you this:
Code:
Function VerifyUsername(username As String) As Boolean
'This is where the code to check the username entered against the username array should go
'If the username is found, Return True, otherwise Return False
End Function
Function VerifyPassword(password As String) As Boolean
'This is where the code to check the password entered against the password tied to the found username should go
'If the passwords match, Return True, otherwise Return False
End Function
Also, in your Form code, I don't see anywhere that you are actually calling the Login Sub and passing the username and password. Before you check the value of blnLoggedIn, you need to be doing something like:
Code:
Login(txtUsername.Text, txtPassword.Text)
That's as much as I will assist with this issue, I hope you are able to get this working.
-
Jan 19th, 2018, 02:55 PM
#12
Re: Please Help!! Im on a deadline and I cant figure this out!!
A couple of things, I don't see any code that calls "Sub Login"
Try putting a Break Point at this line "If arrUsernames(loopIndex) = username Then", then you can check the values and you should have a better picture of what's going on.
-
Jan 19th, 2018, 03:22 PM
#13
Thread Starter
Addicted Member
Re: Please Help!! Im on a deadline and I cant figure this out!!
Originally Posted by wes4dbt
A couple of things, I don't see any code that calls "Sub Login"
Try putting a Break Point at this line "If arrUsernames(loopIndex) = username Then", then you can check the values and you should have a better picture of what's going on.
Thats the part Im having trouble with is figuring out...''This is where the code to check the password entered against the password tied to the found username should go" and same for username.
The part about calling the login sub has confused me and how to get each username connected with the certain password. I dont understand how to connect the two
-
Jan 19th, 2018, 03:46 PM
#14
Re: Please Help!! Im on a deadline and I cant figure this out!!
OptionBase1 gave you an example of calling the Login Sub. You would put it before this "If Main.blnLoggedIn Then". Then if it's still no working then put the Break Point like I mentioned before.
-
Jan 19th, 2018, 04:04 PM
#15
Thread Starter
Addicted Member
Re: Please Help!! Im on a deadline and I cant figure this out!!
This is my first time using this program so thats why I dont know how to do much..I put it before "If Main.blnLoggedIn" already...Does anything need to come after that?
Also Im still stuck on how to put the function code in to match each username to its password..Im close to giving up this is getting irritating ughh
-
Jan 19th, 2018, 04:37 PM
#16
Re: Please Help!! Im on a deadline and I cant figure this out!!
Quite often, classes don't bother with teaching people the simple debugging tools that each of us uses nearly every day, so start off with that: Do you know how to set breakpoints? Do you know then how to step through the code?
If you answer no to either of those, then those are the first things to learn, because without those tools you are just guessing. However, if you DO know those two items, then put a breakpoint on the first line of the Login method and run the code. You will see that the breakpoint is never reached. That's not by chance. It means that the code isn't reached. So, when do you think it SHOULD have been reached? The user would have to have a chance to enter a username and password, so it would have to be on a click event. That is where the method should be called.
My usual boring signature: Nothing
-
Jan 19th, 2018, 05:31 PM
#17
Thread Starter
Addicted Member
Re: Please Help!! Im on a deadline and I cant figure this out!!
No I dont know how to do either of those things
-
Jan 19th, 2018, 05:48 PM
#18
Thread Starter
Addicted Member
Re: Please Help!! Im on a deadline and I cant figure this out!!
Ive been trying to figure this issue out for 3 days now and Im not getting any closer to understanding this and im on a deadline
-
Jan 19th, 2018, 05:58 PM
#19
Re: Please Help!! Im on a deadline and I cant figure this out!!
That's a funny thing about classes. I think that debugging should be the second thing covered, but it is often not covered at all. Without that, the best you can do is stare at the code hoping for inspiration, which doesn't work well for experienced coders, let alone somebody just starting out.
To set a breakpoint, put the cursor on the line you want to set the breakpoint on and press F9. This should hightlight the line in maroon and add a maroon ball in the left margin. Once you see where that ball is, you can add and remove breakpoints just by clicking in that margin, which saves you the need to press F9, or position the cursor.
You can set breakpoints on most lines, but not whitespace, comments, or variable declarations that lack initialization. In other words, you can't set one on this line:
Dim x As Integer
but you could on this line:
Dim x As Integer = 5
Once you have set a breakpoint, when you run the code, execution will pause when the breakpoint is reached, and you will be taken to the code. At that point, you can see what is in every variable that is in scope. Generally, you can hover the mouse over the variable and a tooltip will show you what it contains. Sometimes that doesn't work, though, in which case you can always highlight the variable and press Shift+F9. In fact, you can highlight more than just a variable and do this. For example:
If x > 5 Then
You could highlight the "x > 5" part and press Shift + F9 and you will see how that expression evaluates (so, either True or False). If you highlight a class and press Shift+F9, you can look at all the properties and settings of the class. That's pretty powerful.
Next, you can press either F10 or F11 to step forwards through the code line by line. F10 does something different from F11, but I'll leave that up to you to play with.
Finally, at any time you can resume normal operation with F5.
So, by setting breakpoints and stepping through the code, you can see what variables hold, how they change, which branch execution takes at any If statements, and by looking at the conditions, you can see why execution took that path. Instead of a black box, you see what the computer sees, what every variable holds, and what the computer is doing. Without that, code is like being asked to fix a balky engine without being able to see what it is doing.
My usual boring signature: Nothing
-
Jan 21st, 2018, 01:19 AM
#20
Thread Starter
Addicted Member
Re: Please Help!! Im on a deadline and I cant figure this out!!
Originally Posted by Shaggy Hiker
That's a funny thing about classes. I think that debugging should be the second thing covered, but it is often not covered at all. Without that, the best you can do is stare at the code hoping for inspiration, which doesn't work well for experienced coders, let alone somebody just starting out.
To set a breakpoint, put the cursor on the line you want to set the breakpoint on and press F9. This should hightlight the line in maroon and add a maroon ball in the left margin. Once you see where that ball is, you can add and remove breakpoints just by clicking in that margin, which saves you the need to press F9, or position the cursor.
You can set breakpoints on most lines, but not whitespace, comments, or variable declarations that lack initialization. In other words, you can't set one on this line:
Dim x As Integer
but you could on this line:
Dim x As Integer = 5
Once you have set a breakpoint, when you run the code, execution will pause when the breakpoint is reached, and you will be taken to the code. At that point, you can see what is in every variable that is in scope. Generally, you can hover the mouse over the variable and a tooltip will show you what it contains. Sometimes that doesn't work, though, in which case you can always highlight the variable and press Shift+F9. In fact, you can highlight more than just a variable and do this. For example:
If x > 5 Then
You could highlight the "x > 5" part and press Shift + F9 and you will see how that expression evaluates (so, either True or False). If you highlight a class and press Shift+F9, you can look at all the properties and settings of the class. That's pretty powerful.
Next, you can press either F10 or F11 to step forwards through the code line by line. F10 does something different from F11, but I'll leave that up to you to play with.
Finally, at any time you can resume normal operation with F5.
So, by setting breakpoints and stepping through the code, you can see what variables hold, how they change, which branch execution takes at any If statements, and by looking at the conditions, you can see why execution took that path. Instead of a black box, you see what the computer sees, what every variable holds, and what the computer is doing. Without that, code is like being asked to fix a balky engine without being able to see what it is doing.
ok I will that a try and see how it goes! Thank you for your help!!
-
Jan 22nd, 2018, 03:23 PM
#21
Thread Starter
Addicted Member
Re: Please Help!! Im on a deadline and I cant figure this out!!
Originally Posted by Shaggy Hiker
That's a funny thing about classes. I think that debugging should be the second thing covered, but it is often not covered at all. Without that, the best you can do is stare at the code hoping for inspiration, which doesn't work well for experienced coders, let alone somebody just starting out.
To set a breakpoint, put the cursor on the line you want to set the breakpoint on and press F9. This should hightlight the line in maroon and add a maroon ball in the left margin. Once you see where that ball is, you can add and remove breakpoints just by clicking in that margin, which saves you the need to press F9, or position the cursor.
You can set breakpoints on most lines, but not whitespace, comments, or variable declarations that lack initialization. In other words, you can't set one on this line:
Dim x As Integer
but you could on this line:
Dim x As Integer = 5
Once you have set a breakpoint, when you run the code, execution will pause when the breakpoint is reached, and you will be taken to the code. At that point, you can see what is in every variable that is in scope. Generally, you can hover the mouse over the variable and a tooltip will show you what it contains. Sometimes that doesn't work, though, in which case you can always highlight the variable and press Shift+F9. In fact, you can highlight more than just a variable and do this. For example:
If x > 5 Then
You could highlight the "x > 5" part and press Shift + F9 and you will see how that expression evaluates (so, either True or False). If you highlight a class and press Shift+F9, you can look at all the properties and settings of the class. That's pretty powerful.
Next, you can press either F10 or F11 to step forwards through the code line by line. F10 does something different from F11, but I'll leave that up to you to play with.
Finally, at any time you can resume normal operation with F5.
So, by setting breakpoints and stepping through the code, you can see what variables hold, how they change, which branch execution takes at any If statements, and by looking at the conditions, you can see why execution took that path. Instead of a black box, you see what the computer sees, what every variable holds, and what the computer is doing. Without that, code is like being asked to fix a balky engine without being able to see what it is doing.
I have tried using Shift+F9 and nothing happens..I have put in so many if statements and I keep getting that same error...Im still confused on all of this. Im not getting anywhere
-
Jan 22nd, 2018, 03:55 PM
#22
Re: Please Help!! Im on a deadline and I cant figure this out!!
Hi,
do you have to use two Arrays ?
Code:
Dim arrUsernames() As String = {"Admin, Clerk, Manager"}
Dim arrPasswords() As String = {"P@ssword, pa$$word, and passw0rd"}
would it not be better to combined, somthing like this...
Code:
Public Class Form3
Public Sub lvwAddItem(ByVal lvw As ListView, ByVal ParamArray Text() As String)
With lvw.Items
.Add(New ListViewItem(Text))
End With
End Sub
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
With ListView1
.View = View.Details
.LabelEdit = False
.HideSelection = False
.GridLines = True
.CheckBoxes = True
.FullRowSelect = True
.Columns.Add("User", 120)
.Columns.Add("Password", 120)
End With
lvwAddItem(ListView1, "Admin", "AdminPassword")
lvwAddItem(ListView1, "Clerk", "ClerkPassword")
'etc....
End Sub
End Class
regards
Chris
to hunt a species to extinction is not logical !
since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.
-
Jan 22nd, 2018, 04:01 PM
#23
Thread Starter
Addicted Member
Re: Please Help!! Im on a deadline and I cant figure this out!!
Originally Posted by ChrisE
Hi,
do you have to use two Arrays ?
Code:
Dim arrUsernames() As String = {"Admin, Clerk, Manager"}
Dim arrPasswords() As String = {"P@ssword, pa$$word, and passw0rd"}
would it not be better to combined, somthing like this...
Code:
Public Class Form3
Public Sub lvwAddItem(ByVal lvw As ListView, ByVal ParamArray Text() As String)
With lvw.Items
.Add(New ListViewItem(Text))
End With
End Sub
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
With ListView1
.View = View.Details
.LabelEdit = False
.HideSelection = False
.GridLines = True
.CheckBoxes = True
.FullRowSelect = True
.Columns.Add("User", 120)
.Columns.Add("Password", 120)
End With
lvwAddItem(ListView1, "Admin", "AdminPassword")
lvwAddItem(ListView1, "Clerk", "ClerkPassword")
'etc....
End Sub
End Class
regards
Chris
Yes I have to use both arrays and come up with Return statement for each. My instructions say this:
Using what you know about search arrays, implement the VerifyUsername and VerifyPassword functions. They should return true if the username or password is found in the arrUsernames or arrPasswords array, respectively.
You should get an error message using the blnLoggedIn variable.
-
Jan 22nd, 2018, 04:06 PM
#24
Re: Please Help!! Im on a deadline and I cant figure this out!!
Originally Posted by ChrisE
Hi,
Did you read the first post in this thread? The directions provided in the first post specifically state to use arrays. How exactly do think putting the data in a ListView solves anything here? All your post will do is confuse the poster even more since the code you posted accomplishes exactly 0 towards the end goal of the program.
-
Jan 22nd, 2018, 04:42 PM
#25
Thread Starter
Addicted Member
Re: Please Help!! Im on a deadline and I cant figure this out!!
Can anyone tell me how to do this? I have to turn it in by the end of today
-
Jan 22nd, 2018, 04:51 PM
#26
Re: Please Help!! Im on a deadline and I cant figure this out!!
Originally Posted by EmilyM1105
I have to turn it in by the end of today
Hate to say it, that's not really our issue, is it? We are happy to help but you seem to think we will do your work for you. Given the number of posts so far what have you tried?
-
Jan 22nd, 2018, 04:56 PM
#27
Thread Starter
Addicted Member
Re: Please Help!! Im on a deadline and I cant figure this out!!
Originally Posted by ident
Hate to say it, that's not really our issue, is it? We are happy to help but you seem to think we will do your work for you. Given the number of posts so far what have you tried?
No one said it was anyones issue but my own. Have you not read any of my posts? I have tried everything everyone on here has suggested and nothing has worked. This forum was my last resort I have been doing this project on my own before I even came on here!! Ive done almost all of it myself so what do you mean what have I done??! I asked for help on this part that was it
-
Jan 22nd, 2018, 05:00 PM
#28
Re: Please Help!! Im on a deadline and I cant figure this out!!
Can you post your current Form and Module code?
-
Jan 22nd, 2018, 05:04 PM
#29
Thread Starter
Addicted Member
Re: Please Help!! Im on a deadline and I cant figure this out!!
Originally Posted by OptionBase1
Can you post your current Form and Module code?
This is my Main.vb code
Code:
Module Main
Friend blnLoggedIn As Boolean
Dim arrUsernames() As String = {"Admin, Clerk, Manager"}
Dim arrPasswords() As String = {"P@ssword, pa$$word, and passw0rd"}
Sub Login(username As String, password As String)
blnLoggedIn = False
If VerifyUsername(username) And VerifyPassword(password) Then
'Find index for username
Dim userIndex As Integer
For loopIndex = 0 To arrUsernames.Length - 1
If arrUsernames(loopIndex) = username Then
userIndex = loopIndex
Exit For
End If
Next
'Check for password match
If arrPasswords(userIndex) = password Then
blnLoggedIn = True
Else
MessageBox.Show(“Incorrect password.”)
End If
End If
End Sub
Function VerifyUsername(username As String) As Boolean
'If the username is found, Return True, otherwise Return False
End Function
Function VerifyPassword(password As String) As Boolean
'If the passwords match, Return True, otherwise Return False
End Function
End Module
This is my LoginForm.vb code
Code:
Public Class LoginForm
Private Sub Label1_Click(sender As Object, e As EventArgs) Handles lblUsername.Click, btnLogin.Click
If Main.blnLoggedIn Then
MessageBox.Show(“Thank you for logging in, “ & txtUsername.Text, “Logged In.”)
Me.Close()
End If
End Sub
Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click
Application.Exit()
End Sub
End Class
-
Jan 22nd, 2018, 05:20 PM
#30
Re: Please Help!! Im on a deadline and I cant figure this out!!
Your code was close enough to demonstrate that you know most of what you are intended to do. You still don't have any of the code for checking the username and password inside of the actual VerifyUsername and VerifyPassword functions, and you're never calling the Login method, which I and others pointed out.
If you make the bolded changes below your program should work, but you likely won't get full credit due to not implementing the specified functions completely. Note that the line that says:
Login(txtUsername.text, txtPassword.text), you'll need to replace txtUsername and txtPassword if the names of your Username and Password textboxes are different.
Originally Posted by EmilyM1105
This is my Main.vb code
Code:
Module Main
Friend blnLoggedIn As Boolean
Dim arrUsernames() As String = {"Admin, Clerk, Manager"}
Dim arrPasswords() As String = {"P@ssword, pa$$word, and passw0rd"}
Sub Login(username As String, password As String)
blnLoggedIn = False
If VerifyUsername(username) And VerifyPassword(password) Then
'Find index for username
Dim userIndex As Integer
For loopIndex = 0 To arrUsernames.Length - 1
If arrUsernames(loopIndex) = username Then
userIndex = loopIndex
Exit For
End If
Next
'Check for password match
If arrPasswords(userIndex) = password Then
blnLoggedIn = True
Else
MessageBox.Show(“Incorrect password.”)
End If
End If
End Sub
Function VerifyUsername(username As String) As Boolean
'If the username is found, Return True, otherwise Return False
Return True
End Function
Function VerifyPassword(password As String) As Boolean
'If the passwords match, Return True, otherwise Return False
Return True
End Function
End Module
This is my LoginForm.vb code
Code:
Public Class LoginForm
Private Sub Label1_Click(sender As Object, e As EventArgs) Handles lblUsername.Click, btnLogin.Click
Login(txtUsername.Text, txtPassword.text)
If Main.blnLoggedIn Then
MessageBox.Show(“Thank you for logging in, “ & txtUsername.Text, “Logged In.”)
Me.Close()
End If
End Sub
Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click
Application.Exit()
End Sub
End Class
-
Jan 22nd, 2018, 05:21 PM
#31
Re: Please Help!! Im on a deadline and I cant figure this out!!
A new topic has the power to alienate senior programmers here that include no description. Why should I of had to ask for updated code. Do you not think this would help me?
Ok, let's take this a step at a time. Have you been asked to use Module-level variables? In fact, just using a module.... Dim should only be used for local variables only. I'm hardly shocked but I would bring this up with him/her. More so there is no logic for it to be set to friend.
vb Code:
Private _isLoggedIn As Boolean Private _userNames As String() Private _Passwords As String()
so far make sense?
-
Jan 22nd, 2018, 05:27 PM
#32
Thread Starter
Addicted Member
Re: Please Help!! Im on a deadline and I cant figure this out!!
Originally Posted by OptionBase1
Your code was close enough to demonstrate that you know most of what you are intended to do. You still don't have any of the code for checking the username and password inside of the actual VerifyUsername and VerifyPassword functions, and you're never calling the Login method, which I and others pointed out.
If you make the bolded changes below your program should work, but you likely won't get full credit due to not implementing the specified functions completely. Note that the line that says:
Login(txtUsername.text, txtPassword.text), you'll need to replace txtUsername and txtPassword if the names of your Username and Password textboxes are different.
I did make those changes but I was still getting errors so I erased them and kept what I originally had in the code. I did change the TxtUsername and txtpassword but it keeps saying its not declared so I took it off
-
Jan 22nd, 2018, 05:30 PM
#33
Thread Starter
Addicted Member
Re: Please Help!! Im on a deadline and I cant figure this out!!
Originally Posted by ident
A new topic has the power to alienate senior programmers here that include no description. Why should I of had to ask for updated code. Do you not think this would help me?
Ok, let's take this a step at a time. Have you been asked to use [FONT="]Module-level variables? In fact, just using a module.... [/FONT][FONT="] Dim should only be used for local variables only. I'm hardly shocked but I would bring this up with him/her. More so there is no logic for it to be set to friend.
vb Code:
Private _isLoggedIn As Boolean Private _userNames As String() Private _Passwords As String()
so far make sense?
No actually nothing you just said makes sense.
-
Jan 22nd, 2018, 05:30 PM
#34
Re: Please Help!! Im on a deadline and I cant figure this out!!
Listen, put the code like OptionBase1 showed and then tell (or show) us exactly what the error says and on which line of code the error occurs.
-
Jan 22nd, 2018, 05:31 PM
#35
Re: Please Help!! Im on a deadline and I cant figure this out!!
See this is your issue. NO INFORMATION. i cant magically know whats not declared. If you are not going to make an effort thinking we have magic crystal balls il remove my self from notifications.
-
Jan 22nd, 2018, 05:33 PM
#36
Thread Starter
Addicted Member
Re: Please Help!! Im on a deadline and I cant figure this out!!
Just forget it Im not getting any help here I just keep repeating myself.
-
Jan 22nd, 2018, 05:34 PM
#37
Thread Starter
Addicted Member
Re: Please Help!! Im on a deadline and I cant figure this out!!
So remove yourself then! You havent helped me with anything anyways!!
-
Jan 22nd, 2018, 05:35 PM
#38
Thread Starter
Addicted Member
Re: Please Help!! Im on a deadline and I cant figure this out!!
I put in the username and passwords in place of what Optionbase said and it keeps saying that each of the login and passwords arent declared!
-
Jan 22nd, 2018, 05:37 PM
#39
Re: Please Help!! Im on a deadline and I cant figure this out!!
This is like pulling teeth. When someone says exactly they mean exactly. And you still didn't bother to display which line of code is causing the error.
-
Jan 22nd, 2018, 05:39 PM
#40
Re: Please Help!! Im on a deadline and I cant figure this out!!
Is it is the Login(txtUsername.Text, txtPassword.Text) line? What is the exact error?
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
|