Jump to content
igadino

Rolar automaticamente

Recommended Posts

igadino

Estou tentando lista os id's do cliente automaticamente no TextBox1 ai tudo bem, porem estou tentando

fazer um loop para lista vou usar com intervalo de tempo para passa de um em um mais não estou 

conseguindo sou iniciante em programação se eu estiver ajuda dos programadores poderei

tentar seguir esta carreira. tem alguém que pode me dar um HELP.

Private Sub listeId()
        Dim mostrar As Boolean = True
        Using con As OleDbConnection = GetConnection()
            con.Open()
            Dim busca As String = ""
            busca = "SELECT * FROM Cadastro"
            Dim conectar As OleDbCommand
            conectar = New OleDbCommand(busca, con)
            Dim ligar As OleDbDataAdapter = New OleDbDataAdapter(conectar)
            Dim tabela As DataSet = New DataSet()
            Try
                ligar.Fill(tabela, "Cadastro")
                Dim conte As Integer = 0
                Do While (mostrar = True)
                    TextBox1.Text = tabela.Tables(0).Rows(conte).Item("CodCadastro")
                    Dim t As New System.Timers.Timer(5000)
                    conte += 1
                    If conte > tabela.Tab
les(0).Rows.Count - 1 Then
                        conte = 0
                    End If
                Loop
                con.Close()
            Catch ex As Exception
            End Try 
End Using

Share this post


Link to post
Share on other sites
vikcch

em vez de:

Dim t As New System.Timers.Timer(5000)

coloca:

		    Application.DoEvents()
	    Threading.Thread.Sleep(5000)

vai-te é congelar a aplicação durante esses 5 segundos, mesmo com o DoEvents...

dá pra usar o timer mas fica um pouco mais complicado

Share this post


Link to post
Share on other sites
ribeiro55

Não podes usar um ciclo While para o que pretendes. Estes ciclos não servem para isso por mais razões do que simplesmente bloquearem a thread.

Passa a tua lógica de incremento para o handler do event Tick de um Timer.

Dessa forma o teu código corre pontualmente de x em x tempo.


Sérgio Ribeiro


"Great coders aren't born. They're compiled and released"
"Expert coders do not need a keyboard. They just throw magnets at the RAM chips"

Share this post


Link to post
Share on other sites
igadino

Resolvido segue exemplo para aguem precisar.

Private Sub ListaPublicidade()

On Error Resume Next

Using con As OleDbConnection = GetConnection()

con.Open()

Dim busca As String = ""

busca = "SELECT * FROM tblImagensPDV"

Dim conectar As OleDbCommand

conectar = New OleDbCommand(busca, con)

Dim ligar As OleDbDataAdapter = New OleDbDataAdapter(conectar)

Dim tabela As DataSet = New DataSet()

ligar.Fill(tabela, "tblImagensPDV")

Dim img As String = tabela.Tables(0).Rows(conte).Item("enderecoimagem") '.ToString

Me.Refresh()

ImgSalvar.Image = System.Drawing.Bitmap.FromFile(img)

conte += 1

If conte > tabela.Tables(0).Rows.Count - 1 Then

conte = 0

End If

con.Close()

End Using

Timer2.Enabled = True

End Sub

  • Vote 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.