Help with PIN access program

Con07

New member
Joined
Nov 16, 2014
Messages
1
Programming Experience
Beginner
I've been given an assignment to create a simple login that resembles a bank login and will open a new form that will give you access to change the balance of the bank account. The problem that i'm having is that when i hit enter with the correct PIN it will give the error message as it should when the entered PIN was wrong. i have replaced the error message with a messagebox to show what the listview recognises is there and it always returns a blank despite there being numbers inside the listview.
Heres the code:
Public Class Form1
    Dim Number As String
    Dim ListItem1 As ListViewItem
    Dim ListItem2 As ListViewItem
    Dim ListItem3 As ListViewItem
    Dim ListItem4 As ListViewItem
    Dim ListItem5 As ListViewItem
    Dim ListItem6 As ListViewItem
    Dim ListItem7 As ListViewItem
    Dim ListItem8 As ListViewItem
    Dim ListItem9 As ListViewItem
    Dim ListItem0 As ListViewItem
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        ListItem1 = ListView1.Items.Add(1)
    End Sub


    Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
        ListItem2 = ListView1.Items.Add(2)
    End Sub


    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        ListItem3 = ListView1.Items.Add(3)
    End Sub


    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        ListItem4 = ListView1.Items.Add(4)
    End Sub


    Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
        ListItem5 = ListView1.Items.Add(5)
    End Sub


    Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
        ListItem6 = ListView1.Items.Add(6)
    End Sub


    Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
        ListItem7 = ListView1.Items.Add(7)
    End Sub


    Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
        ListItem8 = ListView1.Items.Add(8)
    End Sub


    Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click
        ListItem9 = ListView1.Items.Add(9)
    End Sub


    Private Sub Button10_Click(sender As Object, e As EventArgs) Handles Button10.Click
        ListItem0 = ListView1.Items.Add(0)
    End Sub


    Private Sub Button11_Click(sender As Object, e As EventArgs) Handles Button11.Click
        Me.Close()
    End Sub


    Private Sub Button12_Click_1(sender As Object, e As EventArgs) Handles Button12.Click
        Dim Number As String
        Number = ListView1.Text
        If Number = "6721" Then
            Form2.Show()
            Me.Hide()
        Else
            MessageBox.Show("Error - Invalid Pin")
            ListView1.Clear()
        End If
    End Sub
End Class


And here is an example of what happens:
Form with error.png

I've looked around but i cant find anything that explains this, can someone tell me where the error is and what to change?

Much appreciated.
 
Last edited by a moderator:
Not that there aren't other issues with your code but the specific issue you've raised is rooted here:
VB.NET:
Number = ListView1.Text
Is it really the Text of the actual ListView you want, or perhaps the Text from one or more items in the ListView?
 
Back
Top