Visual Basic.NET - Problema al buscar texto según fecha

 
Vista:
sin imagen de perfil
Val: 229
Ha disminuido 1 puesto en Visual Basic.NET (en relación al último mes)
Gráfica de Visual Basic.NET

Problema al buscar texto según fecha

Publicado por José Vicente (113 intervenciones) el 24/05/2021 20:53:54
Hola, tengo un botón con el que hago una búsqueda en un fichero de texto de una cadena y contar las veces que se repite, el problema es que no sé como buscar esa cadena según una fecha dada.
O sea, intento que aparezca en un textbox el numero de veces que se repite una cadena de texto para una fecha dada en ese mismo fichero. No sé si me he explicado bien.
Mi código es:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
Private Sub cantidadesKuga_btn_Click(sender As Object, e As EventArgs) Handles cantidadesKuga_btn.Click
 
    Dim vlcCriterio As String = Pnumber1_tbox.Text
    Dim contador As Int16 = 0
    Dim hoy As Date = Today
    Dim mañana As Date = hoy.AddDays(1)
    Dim pasado As Date = hoy.AddDays(2)
    Dim otro As Date = hoy.AddDays(3)
    Dim otromas As Date = hoy.AddDays(4)
    Dim otro1 As Date = hoy.AddDays(5)
 
    ' NOMBRE DEL FICHERO A UTILIZAR
 
    Dim vlcFileName As String = fichero_tbox.Text
 
    ' SI EXISTE
 
    If File.Exists(vlcFileName) Then
 
        ' CREAMOS EL STREAM
 
        Dim vloFile As New StreamReader(vlcFileName)
 
        ' LEEMOS LAS LÍNEAS
 
        While True
 
            ' CARGAMOS LA LÍNEA
 
            Dim vlcLinea = vloFile.ReadLine()
 
            ' SI NO EXISTE LA LÍNEA SALIMOS DEL CICLO
 
            If vlcLinea Is Nothing Then Exit While
 
            ' SI LA LÍNEA CONTIENE EL TEXTO BUSCADO
 
            If vlcLinea.Contains(vlcCriterio) Then
 
                contador += 1
 
            End If
 
        End While
 
        dia1_tbox.Text = contador
 
    End If
 
    ' SI NO HAY COINCIDENCIAS
 
    If contador = 0 Then dia1_tbox.Text = 0
 
End Sub

Podéis echarme un cable. Gracias.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder