0

I have a code:

Private Sub OK_Click()


Dim Username As String

Username = InputBox("Username")

If Username = "Martyna" Then
MsgBox "Welcome, " & Username

Else: MsgBox "Sorry, access is denied, please Check your username and try again"

End If
End Sub

and it should ask 3 time for username then if it's not correct display message : 'sorry, access is denied, please Check your username and try again'

i have to use loop but i dont know how to do it.
any help?

5
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by vb5prgrmr
0

1. declare a byte variable
2. check the value for 3>= before prompting for inputbox
3. increment the value by by 1 after the inputbox

0

do you know, using looping condition is so hard to code,, but lets try to search.... i know it have article that can help you.... gudluck

0

' Try this do while loop

I have a code:

Private Sub OK_Click()


Dim Username As String
dim cnt as integer

cnt=1
do while (cnt<=3)

Username = InputBox("Username")

If Username = "Martyna" Then
MsgBox "Welcome, " & Username
exit do

Else: MsgBox "Sorry, access is denied, please Check your username and try again"
cnt=cnt-1
End If
loop

End Sub

and it should ask 3 time for username then if it's not correct display message : 'sorry, access is denied, please Check your username and try again'

i have to use loop but i dont know how to do it.
any help?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.