igadino Posted January 30, 2016 at 02:54 PM Report Share #592807 Posted January 30, 2016 at 02:54 PM 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 Link to comment Share on other sites More sharing options...
vikcch Posted January 30, 2016 at 08:34 PM Report Share #592823 Posted January 30, 2016 at 08:34 PM 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 Link to comment Share on other sites More sharing options...
igadino Posted January 31, 2016 at 01:17 PM Author Report Share #592837 Posted January 31, 2016 at 01:17 PM Mais como eu faço para não congelar a aplicação e as imagens ficar passando tem jeito? Link to comment Share on other sites More sharing options...
ribeiro55 Posted February 1, 2016 at 12:06 PM Report Share #592862 Posted February 1, 2016 at 12:06 PM 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" Link to comment Share on other sites More sharing options...
igadino Posted February 3, 2016 at 11:19 PM Author Report Share #593079 Posted February 3, 2016 at 11:19 PM 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 1 Report Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now