Click here to Skip to main content
16,004,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When reading a QR code that is printed, the system does not show confirmation of what you want to do by executing a msgbox, but rather directly assumes the NO value of the msgbox. Reading is done with a code reader

I validate the QR code in the TextChanged of a Textbox control, when the maximum length of the Textbox control is reached, which is 6 characters.

The code that I make in the QR capture textbox is:

What I have tried:

VB
Private Sub txtBusquedaOrden_TextChanged(sender As Object, e As EventArgs) Handles txtBusquedaOrden.TextChanged
    If Len(txtBusquedaOrden.Text) = txtBusquedaOrden.MaxLength Then
       Dim NumeroOrden As Long = Val(txtBusquedaOrden.Text)

       Try
           Dim style = MsgBoxStyle.YesNoCancel Or MsgBoxStyle.DefaultButton2 Or MsgBoxStyle.Information

          Dim msg As String = "ORDEN No. " & NumeroOrden & vbCrLf & vbCrLf & "Seleccione : " & vbCrLf & "SI para CARGAR ORDEN" & vbCrLf & "NO para CERRAR ORDEN " & vbCrLf
           Dim title As String = "Orden"
           Dim response = MsgBox(msg, style, title)

           Select Case response
               Case Is = 6
                   CargaOrdendesdeQR(NumeroOrden)
                   txtBusquedaOrden.Text = ""
                   txtBusquedaOrden.Focus()
               Case Is = 7
                   CierraOrdendesdeQR(NumeroOrden)
                   txtBusquedaOrden.Text = ""
                   txtBusquedaOrden.Focus()
               Case Else
                   txtBusquedaOrden.Text = ""
                   txtBusquedaOrden.Focus()
           End Select
       Catch ex As Exception
           MessageBox.Show(ex.Message, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
       End Try
    End If
End Sub
Posted

We can't run that code under the same conditions you do - we have no access to your scanner or the codes it is scanning.

But there are two possible options: that method is not being executed at all, or the length is not exactly equal to the limit you specified.
Use the debugger: put a breakpoint on the first line of the method and see if the method is executed at all. If it is, step though a line at a time and watch the variables to find out what exactly is happening and why it executes the code it does.

Sorry, but we can't do that for you!
 
Share this answer
 
Comments
Member 12760369 30-Jul-24 11:01am    
Thanks for your answer. I have already done the step by step, line by line, and the code is validating when the character limit in the textbox is reached. When it reaches the msgbox line it is automatically assuming the default msgbox value.
Member 12760369 30-Jul-24 11:16am    
The curious thing is that if I fill the textbox manually with the code to be validated, that is, without reading the QR, the program runs well and the msgbox options are shown to me when completing the length of the text and the maximum value of the textbox.
The situation was solved by deactivating the automatic Enter that was added as a suffix in the reader configuration and it now works as desired. Thank you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900