ASP - is possible trasnform a native VBA macro in asp p

Asked By sal21 sal21 on 20-Mar-05 12:51 PM
Dim var_DATACONT As Date
Dim var_VAL As Date
Dim fso As Object
Dim fil As Object
Dim ExportRecordSet As ADODB.Recordset
Dim PROVADatabase As ADODB.Connection
Set PROVADatabase = New ADODB.Connection
PROVADatabase.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source='" & gPROVADatabasePath & "'; User Id=admin; Password=;"
Set ExportRecordSet = New ADODB.Recordset
ExportRecordSet.Open "TOTALE_NO_EXCEL", PROVADatabase, adOpenKeyset, adLockOptimistic, adCmdTableDirect
ExportRecordSet.Index = "SERVIZIO"
' Create the filesystemobject and open the text file
Set fso = CreateObject("Scripting.FileSystemObject")
vFile = "C:\EPF\L0785.txt"
Set fil = fso.OpenTextFile(vFile)
' Loop through the lines of the text file
Do While Not fil.AtEndOfStream
' Read a line into RIGA
RIGA = fil.ReadLine
' Code to process the line goes here
If Len(Trim(RIGA)) > 0 Then
If InStr(Mid(RIGA, 1, 12), "DATA CONTAB.") > 0 Then
var_DATACONT = Mid(RIGA, 15, 10)
End If
If InStr(Mid(RIGA, 1, 11), "DIPENDENZA:") > 0 Then
var_DIP = Format(Mid(RIGA, 14, 4), "#00000")
End If
If InStr(Mid(RIGA, 5, 1), "-") > 0 And InStr(Mid(RIGA, 13, 1), "-") > 0 Then
var_COD = Mid(RIGA, 1, 3)
End If
If var_COD = "442" Then 'NEW LINE CONTROLLO SOLO SU UN CODICE BATCH
If InStr(Mid(RIGA, 50, 2), "55") Or InStr(Mid(RIGA, 50, 2), "36") > 0 And InStr(Mid(RIGA, 98, 1), "/") > 0 Then
var_NUMCC = Trim(Mid(RIGA, 1, 6))
var_NOME = Trim(Mid(RIGA, 8, 40))
var_CAUS = Mid(RIGA, 50, 2)
var_DARE = Trim(Mid(RIGA, 60, 14))
var_AVERE = Trim(Mid(RIGA, 80, 14))
var_VAL = Mid(RIGA, 96, 10)
var_MITT = Format(Mid(RIGA, 107, 4), "#00000")
var_ANOMAL = Trim(Mid(RIGA, 116, 10))
If Not fil.AtEndOfStream Then
RIGA = fil.ReadLine
var_DESCR = Trim(Mid(RIGA, 10, 36))
var_DESCR2 = Trim(Mid(RIGA, 96, 30))
RIGA = fil.ReadLine
var_ABI = Format(Mid(RIGA, 17, 5), "#00000")
var_CAB = Format(Mid(RIGA, 23, 5), "#00000")
var_IMP_PAG = Trim(Mid(RIGA, 29, 16))
var_nrass = Val(Trim(Mid(RIGA, 45, 10))) * 1
var_MT = Trim(Mid(RIGA, 56, 4))
End If
CONT = CONT + 1
If Not ExportRecordSet.BOF Then
ExportRecordSet.MoveFirst
End If
ExportRecordSet.Seek var_CAUS & "-" & var_ABI & "-" & var_CAB & "-" & var_nrass, adSeekFirstEQ
If ExportRecordSet.EOF = True Then
With ExportRecordSet
.AddNew
.Fields("DATA_CONT") = CStr(var_DATACONT)
.Fields("DIP") = Format((var_DIP), "#0000")
.Fields("COD_BATCH") = var_COD
.Fields("C_C") = Format((var_NUMCC), "#0")
.Fields("NOMINATIVO") = var_NOME
.Fields("CAUS") = var_CAUS
.Fields("DARE") = var_DARE
.Fields("AVERE") = var_AVERE
.Fields("VAL") = CStr(var_VAL)
.Fields("SPORT_MIT") = Format((var_MITT), "#0000")
.Fields("ANOM") = var_ANOMAL
.Fields("DESCR") = var_DESCR
Select Case .Fields("DESCR")
Case "RIMESSA ASSEGNI BANCARI INSOLUTI E P"
.Fields("DESCR") = "RIM. ***. INS. PROT."
End Select
.Fields("CRO") = var_DESCR2
.Fields("ABI") = var_ABI
.Fields("CAB") = var_CAB
.Fields("PAG_IMP") = var_IMP_PAG
Select Case .Fields("PAG_IMP")
Case "IMPAG.N.***.BAN."
.Fields("PAG_IMP") = "IMPAGATO"
Case "PAGATON.***.BAN."
.Fields("PAG_IMP") = "PAGATO"
Case "IMPAG.N.***.CIR."
.Fields("PAG_IMP") = "IMP. A.C."
End Select
.Fields("NR_***") = var_nrass
.Fields("MT") = var_MT
.Fields("SERVIZIO") = var_CAUS & "-" & var_ABI & "-" & var_CAB & "-" & var_nrass
.Update
End With
End If
End If
End If
End If
Loop
ExportRecordSet.Close
Set ExportRecordSet = Nothing
PROVADatabase.Close
Set PROVADatabase = Nothing
' Close the text file and clear the variables
fil.Close
Set fil = Nothing
Set fso = Nothing
End Sub

I am totally confused by your post

Asked By Robbe Morris on 20-Mar-05 08:47 PM
However, you can run VBA macros dynamically at runtime in classic ASP and ASP.NET.  Take the code out of this ASP.NET sample and tweak the syntax to fit your classic ASP environment.
http://www.eggheadcafe.com/articles/create_macro_at_runtime_in_dotnet.asp