Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27355

Help with coding

$
0
0
I have this code and it works but not what I need, how can achieve this without have the textbox array. I am to only have two arrays in this project. Help - guidance appreciated.

Code:

Private Sub btnVerify_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnVerify.Click
        'Declare Variables and arrays
        Dim Minimum() As Integer = {1, 2, 3, 7, 4, 3, 5} 'Hold Minimum range.
        Dim Maximum() As Integer = {3, 6, 5, 9, 8, 5, 8} 'Hold Maximum range.
        Dim textboxes() As String = {txtBox1.Text, txtBox2.Text, txtbox3.Text,
                                    txtBox4.Text, txtBox5.Text, txtBox6.Text, txtBox7.Text} ' hold textbox input
        Dim Number As Integer
        Dim Flag As Boolean = True
        Dim Count As Integer

        For Count = 0 To 6
            If Integer.TryParse(textboxes(Count), Number) Then
                If Number >= Minimum(Count) And Number <= Maximum(Count) Then
                    Flag = True
                Else
                    Flag = False
                End If
            End If
        Next
        If Flag = True Then
            MessageBox.Show("You have successfully entered a valid Pin")
        Else
            Flag = False
            MessageBox.Show("you have entered an incorrect Pin")
        End If
    End Sub


Viewing all articles
Browse latest Browse all 27355

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>