Showing results 1 to 2 of 2

Thread: Convert VBA to VB.NET

  1. #1
    Join Date
    15.09.2016
    Posts
    61

    Default Convert VBA to VB.NET

    Hello,
    I have written the following code in VBA

    Sub CreateBatch_PDF()

    Dim BatchStart As Date
    Dim BatchEnd As Date
    Dim Batchnumber As String
    Dim MyBatchFunction As RtFunction
    Dim MyAMLFunction As RtFunction
    Dim ActualDate As String

    BatchStart = CDate(thisProject.Variables.Item("sBatchStart").Value)BatchEnd = CDate(thisProject.Variables.Item("sBatchEnd").Value)
    Batchnumber = CStr(thisProject.Variables.Item("sBatchNumber").Value)
    Set MyBatchFunction = thisProject.RtFunctions.Item("fc_PDF_Batch")
    Set MyAMLFunction = thisProject.RtFunctions.Item("fc_PDF_AML")
    ActualDate = CStr(Day(Now)) + "-" + CStr(Month(Now)) + "-" + CStr(Year(Now)) + "_" + CStr(Hour(Now)) + "-" + CStr(Minute(Now)) + "-" + CStr(Second(Now))

    MyBatchFunction.DynProperties("Filter.Fct_Filename") = Batchnumber + "_" + Computer + "_Batch_" + ActualDate + ".pdf"
    MyAMLFunction.DynProperties("Filter.TimeFilter.ARVTime1") = BatchStart
    MyAMLFunction.DynProperties("Filter.TimeFilter.ARVTime2") = BatchEnd
    MyAMLFunction.DynProperties("Filter.Fct_Filename") = Batchnumber + "_" + Computer + "_AlarmList_" + ActualDate + ".pdf"

    MyBatchFunction.Start
    MyAMLFunction.Start

    thisProject.Variables.Item("xCreateBatch").Value = 1
    End Sub


    This Makro should Export two PDFs via "Report Viewer: export/print" function.
    Before using the Function, I manipulate The DynPropertiers for the Timefilter and the Filename.

    Here is, what I have tried to convert into VB.NET

    Sub CreateBatch_PDF()
    Dim BatchStart As Date
    Dim BatchEnd As Date
    Dim Batchnumber As String
    Dim MyBatchFunction As zenOn.IRtFunction
    Dim MyAMLFunction As zenOn.IRtFunction
    Dim ActualDate As String


    BatchStart = CDate(Me.Variables.Item("sBatchStart").get_Value)
    BatchEnd = CDate(Me.Variables.Item("sBatchEnd").get_Value)
    Batchnumber = CStr(Me.Variables.Item("sBatchNumber").get_Value)
    MyBatchFunction = Me.RtFunctions.Item("fc_PDF_Batch")
    MyAMLFunction = Me.RtFunctions.Item("fc_PDF_AML")
    ActualDate = CStr(Day(Now)) + "-" + CStr(Month(Now)) + "-" + CStr(Year(Now)) + "_" + CStr(Hour(Now)) + "-" + CStr(Minute(Now)) + "-" + CStr(Second(Now))


    MyBatchFunction.DynProperties("Filter.Fct_Filename") = Batchnumber + "_" + Computer + "_Batch_" + ActualDate + ".pdf"
    MyAMLFunction.DynProperties("Filter.TimeFilter.ARVTime1") = BatchStart
    MyAMLFunction.DynProperties("Filter.TimeFilter.ARVTime2") = BatchEnd
    MyAMLFunction.DynProperties("Filter.Fct_Filename") = Batchnumber + "_" + Computer + "_AlarmList_" + ActualDate + ".pdf"



    MyBatchFunction.Start()
    MyAMLFunction.Start()

    Me.Variables.Item("xCreateBatch").set_Value() = 1


    End Sub



    I have Problems to define the DynProperties and also to write a value to a Variable.

    May someone Help me converting the function?

    Greetings,
    Florian
    Last edited by Florian L. : 18th January 2021 at 12:09

  2. #2
    Join Date
    15.09.2016
    Posts
    61

    Default Re: Convert VBA to VB.NET

    I think I have converted it correct now.

        Public Sub Macro_CreateBatch_PDF()

            Dim BatchStart As Date
            Dim BatchEnd As Date
            Dim Batchnumber As String
            Dim MyBatchFunction As zenOn.IRtFunction
            Dim MyAMLFunction As zenOn.IRtFunction
            Dim MyCELFunction As zenOn.IRtFunction
            Dim ActualDate As String

            BatchStart = CDate(Me.Variables.Item("sBatchStart").get_Value)
            BatchEnd = CDate(Me.Variables.Item("sBatchEnd").get_Value)
            Batchnumber = CStr(Me.Variables.Item("sBatchNumber").get_Value)
            MyBatchFunction = Me.RtFunctions.Item("fc_PDF_Batch")
            MyAMLFunction = Me.RtFunctions.Item("fc_PDF_AML")
            MyCELFunction = Me.RtFunctions.Item("fc_PDF_CEL")
            ActualDate = CStr(Day(Now)) + "-" + CStr(Month(Now)) + "-" + CStr(Year(Now)) + "_" + CStr(Hour(Now)) + "-" + CStr(Minute(Now)) + "-" + CStr(Second(Now))

            MyBatchFunction.set_DynProperties("Filter.Fct_Filename", Batchnumber + "_" + "_Batch_" + ActualDate + ".pdf")
            MyAMLFunction.set_DynProperties("Filter.TimeFilter.ARVTime1", BatchStart)
            MyAMLFunction.set_DynProperties("Filter.TimeFilter.ARVTime2", BatchEnd)
            MyAMLFunction.set_DynProperties("Filter.Fct_Filename", Batchnumber + "_" + "_AlarmList_" + ActualDate + ".pdf")
            MyCELFunction.set_DynProperties("Filter.TimeFilter.ARVTime1", BatchStart)
            MyCELFunction.set_DynProperties("Filter.TimeFilter.ARVTime2", BatchEnd)
            MyCELFunction.set_DynProperties("Filter.Fct_Filename", Batchnumber + "_" + "_AuditTrail_" + ActualDate + ".pdf")

            MyBatchFunction.Start()
            MyAMLFunction.Start()
            MyCELFunction.Start()
            MsgBox("functions executed")
            Me.Variables.Item("xCreateBatch").set_Value(0, 1)
     
        End Sub


Similar Threads

  1. Convert runtime created fpm.cmp
    By brc in forum zenon Supervisor
    Replies: 4
    Last Post: 9th May 2013, 03:25
  2. zenon 5.20 to 5.50 convert
    By huggy in forum Editor and Runtime Setup
    Replies: 1
    Last Post: 13th October 2008, 07:35
  3. convert anything to bit
    By brandt in forum straton / zenon Logic
    Replies: 0
    Last Post: 7th February 2008, 13:04

Posting Rules

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •