vinicius.ferreira Posted February 23, 2014 at 04:08 PM Report #546376 Posted February 23, 2014 at 04:08 PM Olá Pessoal! Estou precisando desenvolver um programa que o usuário digita uma data de inicio e uma data de fim no padrão dd/mm/aaaa 00:00:00. Com o objetivo de iniciar uma contagem por segundos da data inicial fornecida até a data final, depois gerar um arquivo TXT para salvar essas informações 04/11/2012 23:59:56, 04/11/2012 23:59:57, 04/11/2012 23:59:58, 04/11/2012 23:59:59, 05/11/2012 00:00:00, 05/11/2012 00:00:01, 05/11/2012 00:00:02, 05/11/2012 00:00:03, Obrigado!
vikcch Posted February 23, 2014 at 06:51 PM Report #546393 Posted February 23, 2014 at 06:51 PM Olá, não consegues somar os segundos à data ou gerar o TXT ? posta aí o que já tentaste!
vinicius.ferreira Posted February 24, 2014 at 10:49 AM Author Report #546440 Posted February 24, 2014 at 10:49 AM Não consigo somar os segundos à data mesmo o Txt é tranquilo Public Class Form1 Dim a As DateTime = Date.Now Dim b As DateTime = CDate("01-01-1970 00:00:00") Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click MessageBox.Show(DateDiff(DateInterval.Second, a, b).ToString) End Sub
nelsonr Posted February 24, 2014 at 11:10 AM Report #546444 Posted February 24, 2014 at 11:10 AM Algo assim? (cria um timer ativo com o intervalo de 1000 ms) ' Variaveis gerais do form, que vão controlar a data/hora inicial, final e atual Dim startDateTime As DateTime Dim endDateTime As DateTime Dim currenttDateTime As DateTime ' Ao iniciar o form Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load ' Define as datas pretendidas startDateTime = New DateTime(2014, 2, 24, 11, 0, 0) endDateTime = New DateTime(2014, 2, 24, 11, 0, 20) currenttDateTime = startDateTime End Sub ' Evento chamado a cada segundo Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick ' Se ainda não passou a data final If currenttDateTime <= endDateTime Then ' Mostra a data/hora atual Console.WriteLine(currenttDateTime) ' Incrementa um segundo currenttDateTime = currenttDateTime.AddSeconds(1) Else ' Se passou a data final, pára o timer Timer1.Enabled = False End If End Sub
vinicius.ferreira Posted February 24, 2014 at 11:30 AM Author Report #546447 Posted February 24, 2014 at 11:30 AM ele precisa armazenar os dados na sequencia. como mostra no inicio do tópico Ai vou precisar pegar toda essa contagem da data inicial até a data final e salvar em um txt. Obs: serão datas grande tenho arquivos de 5 milhões de linhas
nelsonr Posted February 24, 2014 at 11:36 AM Report #546450 Posted February 24, 2014 at 11:36 AM Ah ok, pensei que era para atualizar o ficheiro de segundo a segundo. Dim startDateTime As New DateTime(2014, 2, 24, 11, 0, 0) Dim endDateTime As New DateTime(2014, 2, 24, 11, 1, 0) Dim currenttDateTime As DateTime = startDateTime ' Using sw As New System.IO.StreamWriter("ficheiro.txt") ' While currenttDateTime <= endDateTime ' sw.WriteLine(currenttDateTime) ' currenttDateTime = currenttDateTime.AddSeconds(1) End While End Using 1 Report
vinicius.ferreira Posted February 24, 2014 at 11:45 AM Author Report #546452 Posted February 24, 2014 at 11:45 AM Obrigado! Funcionou
vinicius.ferreira Posted February 24, 2014 at 06:04 PM Author Report #546509 Posted February 24, 2014 at 06:04 PM Surgiu mais um detalhe ele deve gerar arquivos 5 min depois ficar 25 min sem gerar
nelsonr Posted February 25, 2014 at 10:00 AM Report #546560 Posted February 25, 2014 at 10:00 AM Algo assim? Dim startDateTime As New DateTime(2014, 2, 24, 11, 0, 0) Dim endDateTime As New DateTime(2014, 2, 24, 11, 35, 0) Dim currenttDateTime As DateTime = startDateTime ' Using sw As New System.IO.StreamWriter("ficheiro.txt") ' While currenttDateTime <= endDateTime ' sw.WriteLine(currenttDateTime) ' If (currenttDateTime = startDateTime.AddMinutes(5)) Then currenttDateTime = currenttDateTime.AddMinutes(25) Else currenttDateTime = currenttDateTime.AddSeconds(1) End If End While End Using
vinicius.ferreira Posted February 25, 2014 at 01:19 PM Author Report #546571 Posted February 25, 2014 at 01:19 PM Dim startDateTime As New DateTime(2012, 11, 4, 23, 7, 34) '(2012, 11, 3, 4, 18, 0) Dim endDateTime As New DateTime(2013, 11, 22, 13, 48, 53) '(2013, 11, 22, 13, 48, 53) Dim currenttDateTime As DateTime = startDateTime Dim contador As Integer Using sw As New System.IO.StreamWriter("Phaze_Concatenado.txt") While currenttDateTime <= endDateTime contador = 0 While contador <= 299 sw.WriteLine(currenttDateTime) currenttDateTime = currenttDateTime.AddSeconds(1) contador = contador + 1 End While currenttDateTime = currenttDateTime.AddMinutes(25) sw.WriteLine(contador) End While End Using MessageBox.Show("Arquivo Gerado com Sucesso") Acabou ficando dessa maneira mesmo, obrigado pela Força
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