Condition access to the next form through inputbox

Asked

Viewed 21 times

-1

I am developing a simple design in basic visual. When you click the button with the Pacman photograph, an inputbox appears.

I intended that in this inputbox, the user would only be able to advance to the next form if I wrote "I am not a robot".

I am already familiar with the Ucase() function to increase input possibilities, but I wanted it to be impossible to insert numbers or to be able to go ahead without writing anything or anything other than the intended.

The problem is, the user can enter anything, up to numbers, which after clicking 2x Ok, advances to the next form regardless of what he writes.

The code (rudimentary and probably wrong) that I tried on the button is this:

Dim input As String
input = InputBox("Para prosseguir escreva: Nao sou um robo", "Verificação de identidade",,,)
If input = "Nao sou um robo" Then
    Me.Hide()
    Form2.Show()
Else
    Do
        input = If(input.Any(Function(c) Not Char.IsLetter(c)), "", input)
    Loop While input <> UCase("Nao sou um robo") Or input = ""
End If

I’d really appreciate any help.

inserir a descrição da imagem aqui

1 answer

0


You can put this code inside a loop While and only allow you to exit by typing the correct value, and using the UCase case ignores uppercase/lowercase:

Dim input As String

' Loop infinito
While True
    input = InputBox("Para prosseguir escreva: Nao sou um robo", "Verificação de identidade",,,)

    If UCase(input) = "NAO SOU UM ROBO" Then
        ' Sai do Loop
        Exit While
    End If
End While

Me.Hide()
Form2.Show()
  • You solved the problem perfectly, I thank you very much!

  • do not forget to accept the answer :)

  • I had no idea, I’m new to the site, thank you!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.