Click here to Skip to main content
15,029,944 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Boa tarde, é possível ajudarem não consigo passar valores de uma variável para um textbox(TxtLer), vou por a parte do código, mas que não funciona.

Obrigado.

Translation:

Good afternoon, it is possible to help I can not pass values from a variable to a textbox (TxtLer), I will put the part of the code, but that does not work.

Thank you.

What I have tried:

VB
Private Function EscreverArray() As Boolean

        Dim EnviarDados As Integer
        Dim LerByte As String = ("MB0")


            For ProcurarValor = 0 To 50 Step 1

                LerValor = plc.Read(LerByte)

                TxtLer.Text = LerValor.ToString

                TrackBar1.Value = LerValor
                EnviarDados = LerValor
                Numero = LerValor
                Numeros(ProcurarValor) = Numero



                System.Threading.Thread.Sleep(200)
            Next

               Return True
    End Function
Posted
Updated 28-May-21 5:44am
v3
Comments
Richard MacCutchan 28-May-21 11:33am
   
"mas que não funciona."
Even in English, which is the language of this website, that tells us nothing.

1 solution

We have no idea what type LerValor is, or what the error you are seeing is. Heck, we don't even know what you do to generate it, or where in that code it happens. It could be at compile time, or at run time - and the solution would be different.
The error message would also influence any answer.

If it's failing at compile time, then double click on the error message and it will take you to the line - read the error carefully and it should give you clues as to what it found.

If it's failing at run time, we can't help you as we can't run your code in isolation, and the plc Read call could well be significant. So, it's going to be up to you. Fortunately, you have a tool available to you which will help you find out what is going on: the debugger. If you don't know how to use it then a quick Google for "Visual Studio debugger" should give you the info you need.

Put a breakpoint on the first line in the function, and run your code through the debugger. Then look at your code, and at your data and work out what should happen manually. Then single step each line checking that what you expected to happen is exactly what did. When it isn't, that's when you have a problem, and you can back-track (or run it again and look more closely) to find out why.

Sorry, but we can't do that for you - time for you to learn a new (and very, very useful) skill: debugging!
   

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