Visual Basic.NET - Pasar de VBA a vb.net

 
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

Pasar de VBA a vb.net

Publicado por José Vicente (113 intervenciones) el 27/05/2021 18:51:20
Hola, tengo una macro de Excel que me gustaría pasar a vb.net para utilizarla en un proyecto que estoy haciendo.
la macro 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
Option Explicit
 
Sub Cantidad_a_Hoy_0()
Dim mDic, line_Ref, line_Date, Mat
Dim Q&, i&, iniTime!
 
With ThisWorkbook: ChDrive .Path: ChDir .Path: End With
Mat = Application.GetOpenFilename("Archivo a procesar, *.txt", Title:="Selecciona el archivo a procesar")
If Mat = False Then Exit Sub
 
iniTime = Timer
Set mDic = CreateObject("Scripting.Dictionary")
 
Close
Open Mat For Input As #1
 
Do
  If Left(line_Ref, 6) = "LIN+++" Then
    Line Input #1, line_Date
    Line Input #1, line_Date
    i = InStr(line_Date, ":")
 
    If DateSerial(Mid(line_Date, 1 + i, 4), Mid(line_Date, 5 + i, 2), Mid(line_Date, 7 + i, 2)) < Date Then
      Q = InStrRev(line_Ref, ":")
      line_Date = Trim(Mid(line_Ref, 7, Q - 7))
      With mDic
        If .Exists(line_Date) Then .Item(line_Date) = 1 + .Item(line_Date) Else .Add line_Date, 1
      End With
    End If
  End If
 
  Line Input #1, line_Ref
Loop Until EOF(1)
Close
 
With [a1].CurrentRegion.Columns("b").Offset(1).Cells
  Mat = .Resize(.Count - 1)
End With
Q = UBound(Mat)
 
For i = 1 To Q
  If mDic.Exists(Mat(i, 1)) Then Mat(i, 1) = mDic.Item(Mat(i, 1)) Else Mat(i, 1) = 0
Next
[h2].Resize(Q) = Mat
 
MsgBox "Procesado en: " & Format(Timer - iniTime, "0.00 seg.")
line_Ref = Empty: line_Date = Empty: mDic = Empty: Mat = Empty
End Sub
¿Puede alguien echarme una mano?. Gracias.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
-1
Responder