PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
[RESOLVED] Please Help!! Im on a deadline and I cant figure this out!!-VBForums
Page 1 of 4 1234 LastLast
Results 1 to 40 of 126

Thread: [RESOLVED] Please Help!! Im on a deadline and I cant figure this out!!

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2018
    Posts
    136

    Resolved [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

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    32,244

    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

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2018
    Posts
    136

    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!!

  4. #4
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,067

    Re: Please Help!! Im on a deadline and I cant figure this out!!

    Not to mention the hosted file is worthless to us.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jan 2018
    Posts
    136

    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???

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jan 2018
    Posts
    136

    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

  7. #7
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    99,441

    Re: Please Help!! Im on a deadline and I cant figure this out!!

    Please use appropriate formatting tags when posting code snippets:
    Quote Originally Posted by EmilyM1105 View Post
    ***Here is my Main.vb code:

    vb.net Code:
    1. Module Main
    2.     Friend blnLoggedIn As Boolean
    3.     Dim arrUsernames() As String = {"Admin, Clerk, Manager"}
    4.     Dim arrPasswords() As String = {"P@ssword, pa$$word, and passw0rd"}
    5.  
    6.     Sub Login(username As String, password As String)
    7.         blnLoggedIn = False
    8.         If VerifyUsername(username) And VerifyPassword(password) Then
    9.             'Find index for username
    10.             Dim userIndex As Integer
    11.             For loopIndex = 0 To arrUsernames.Length - 1
    12.                 If arrUsernames(loopIndex) = username Then
    13.                     userIndex = loopIndex
    14.                     Exit For
    15.                 End If
    16.             Next
    17.             'Check for password match
    18.             If arrPasswords(userIndex) = password Then
    19.                 blnLoggedIn = True
    20.             Else
    21.                 MessageBox.Show(“Incorrect password.”)
    22.             End If
    23.         End If
    24.  
    25.     End Sub
    26.     Function VerifyUsername(username As String) As Boolean
    27.  
    28.     End Function
    29.  
    30.     Function VerifyPassword(password As String) As Boolean
    31.  
    32.     End Function
    33.  
    34. End Module



    ****Here is my LoginForm.vb code:

    vb.net Code:
    1. Public Class LoginForm
    2.     Private Sub Label1_Click(sender As Object, e As EventArgs) Handles lblUsername.Click, btnLogin.Click
    3.         If Main.blnLoggedIn Then
    4.             MessageBox.Show(“Thank you for logging in, “ & txtUsername.Text, “Logged In.”)
    5.             Me.Close()
    6.         End If
    7.  
    8.     End Sub
    9.  
    10.     Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click
    11.         Application.Exit()
    12.     End Sub
    13. 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
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  8. #8
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    99,441

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Jan 2018
    Posts
    136

    Re: Please Help!! Im on a deadline and I cant figure this out!!

    Quote Originally Posted by jmcilhinney View Post
    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

  10. #10
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,067

    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.

  11. #11
    Hyperactive Member
    Join Date
    Nov 2017
    Posts
    372

    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.

  12. #12
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    3,679

    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.

  13. #13

    Thread Starter
    Addicted Member
    Join Date
    Jan 2018
    Posts
    136

    Re: Please Help!! Im on a deadline and I cant figure this out!!

    Quote Originally Posted by wes4dbt View Post
    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

  14. #14
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    3,679

    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.

  15. #15

    Thread Starter
    Addicted Member
    Join Date
    Jan 2018
    Posts
    136

    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

  16. #16
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    32,244

    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

  17. #17

    Thread Starter
    Addicted Member
    Join Date
    Jan 2018
    Posts
    136

    Re: Please Help!! Im on a deadline and I cant figure this out!!

    No I dont know how to do either of those things

  18. #18

    Thread Starter
    Addicted Member
    Join Date
    Jan 2018
    Posts
    136

    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

  19. #19
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    32,244

    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

  20. #20

    Thread Starter
    Addicted Member
    Join Date
    Jan 2018
    Posts
    136

    Re: Please Help!! Im on a deadline and I cant figure this out!!

    Quote Originally Posted by Shaggy Hiker View Post
    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!!

  21. #21

    Thread Starter
    Addicted Member
    Join Date
    Jan 2018
    Posts
    136

    Re: Please Help!! Im on a deadline and I cant figure this out!!

    Quote Originally Posted by Shaggy Hiker View Post
    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

  22. #22
    Frenzied Member ChrisE's Avatar
    Join Date
    Jun 2017
    Location
    Frankfurt
    Posts
    1,140

    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.

  23. #23

    Thread Starter
    Addicted Member
    Join Date
    Jan 2018
    Posts
    136

    Re: Please Help!! Im on a deadline and I cant figure this out!!

    Quote Originally Posted by ChrisE View Post
    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.

  24. #24
    Hyperactive Member
    Join Date
    Nov 2017
    Posts
    372

    Re: Please Help!! Im on a deadline and I cant figure this out!!

    Quote Originally Posted by ChrisE View Post
    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.

  25. #25

    Thread Starter
    Addicted Member
    Join Date
    Jan 2018
    Posts
    136

    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

  26. #26
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,067

    Re: Please Help!! Im on a deadline and I cant figure this out!!

    Quote Originally Posted by EmilyM1105 View Post
    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?

  27. #27

    Thread Starter
    Addicted Member
    Join Date
    Jan 2018
    Posts
    136

    Re: Please Help!! Im on a deadline and I cant figure this out!!

    Quote Originally Posted by ident View Post
    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

  28. #28
    Hyperactive Member
    Join Date
    Nov 2017
    Posts
    372

    Re: Please Help!! Im on a deadline and I cant figure this out!!

    Can you post your current Form and Module code?

  29. #29

    Thread Starter
    Addicted Member
    Join Date
    Jan 2018
    Posts
    136

    Re: Please Help!! Im on a deadline and I cant figure this out!!

    Quote Originally Posted by OptionBase1 View Post
    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

  30. #30
    Hyperactive Member
    Join Date
    Nov 2017
    Posts
    372

    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.

    Quote Originally Posted by EmilyM1105 View Post
    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

  31. #31
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,067

    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:
    1.  
    vb Code:
    1. Private _isLoggedIn As Boolean
    2.     Private _userNames As String()
    3.     Private _Passwords As String()

    so far make sense?



  32. #32

    Thread Starter
    Addicted Member
    Join Date
    Jan 2018
    Posts
    136

    Re: Please Help!! Im on a deadline and I cant figure this out!!

    Quote Originally Posted by OptionBase1 View Post
    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

  33. #33

    Thread Starter
    Addicted Member
    Join Date
    Jan 2018
    Posts
    136

    Re: Please Help!! Im on a deadline and I cant figure this out!!

    Quote Originally Posted by ident View Post
    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:
    1. [/FONT]
    vb Code:
    1. Private _isLoggedIn As Boolean
    2.     Private _userNames As String()
    3.     Private _Passwords As String()

    so far make sense?


    No actually nothing you just said makes sense.

  34. #34
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    3,679

    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.

  35. #35
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,067

    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.

  36. #36

    Thread Starter
    Addicted Member
    Join Date
    Jan 2018
    Posts
    136

    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.

  37. #37

    Thread Starter
    Addicted Member
    Join Date
    Jan 2018
    Posts
    136

    Re: Please Help!! Im on a deadline and I cant figure this out!!

    So remove yourself then! You havent helped me with anything anyways!!

  38. #38

    Thread Starter
    Addicted Member
    Join Date
    Jan 2018
    Posts
    136

    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!

  39. #39
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    3,679

    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.

  40. #40
    Hyperactive Member
    Join Date
    Nov 2017
    Posts
    372

    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?

Page 1 of 4 1234 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width