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

Need Help with allowing user to re-enter text in textbox during loop

$
0
0
Hey everyone, I got a problem with one of my homeworks. I have to use a Do Until loop until the user enters the right pin in a textbox. However during the loop, I don't know how to allow the user to enter new text into the textbox (it just uses what was written in the textbox and gives error multiple times). I know I can use an input box, but Isn't there a simple way to use the textbox instead?

Here is what I got atm:
Code:

Public Class Form1
    Public pin As Integer
   
    Private Sub Bank()
        Dim correct_pin As Integer = 1347
        Dim Counter As Integer
        Do Until pin = correct_pin Or Counter = 3

            If pin <> correct_pin Then
                Counter += 1

                MsgBox("You have entered the wrong pin, you have " & 3 - Counter & " Attempts left")

                If Counter = 3 Then
                    MsgBox("Your card is blocked, please go to your local branch for assistance")

                End If
            End If
        Loop

        If pin = correct_pin Then
            MsgBox("Welcome to VB Bank")

        End If
    End Sub

    Private Sub Enter_Pin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Start.Click
        pin = TxtMessage.Text
        Bank()

    End Sub

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TxtMessage.TextChanged

    End Sub
End Class

Aprreciate any help. Thanks

Viewing all articles
Browse latest Browse all 27417

Latest Images

Trending Articles



Latest Images

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