我应该将大量用 VBA (Excel) 编写的代码转换为 VB6。但我真的不知道我必须照顾什么或从哪里开始。因此,如果能从 VB6 专家那里得到一些提示,那就太好了。
我已经安装了 MS Visual Studio 并玩了一下。但我不是 VB6 专家,也不知道我必须做什么。
最终目标是将当前放置在一个 excel vba 宏中的所有 VBA 代码放入 VB6 项目中,并从中创建一个 .dll。这个 .dll 应该被 excel 引用,并且 excel 应该像现在一样运行 :-)
例如,我必须做什么才能将此 vba 代码转换为 VB6。
Public Function getParameterNumberOfMaterial() As Integer
10 On Error Resume Next
Dim a As String
20 a = Sheets("Parameters").name
30 If IsNumeric(Application.Worksheets(a).range("C3").Value) Then
40 If Application.Worksheets(a).range("C3").Value > 0 Then
50 getParameterNumberOfMaterial = Application.Worksheets(a).range("C3").Value
60 Else
70 MsgBox "Please check cell C3 in the sheet 'Parameters'. It should include a numeric value which is greater than zero"
80 MsgBox "Parameter Number of Material/Cost is set to the default value of 10"
90 getParameterNumberOfMaterial = 10
100 End If
110 Else
120 MsgBox "Please check cell C3 in the sheet 'Parameters'. It should include a numeric value which is greater than zero"
130 MsgBox "Parameter Number of Material/Cost is set to the default value of 10"
140 getParameterNumberOfMaterial = 10
150 End If
160 On Error GoTo 0
End Function
编辑:是的,如果可以将 vba 代码转换为 .dll 也可以。然后我就不必转换代码了。但我认为只能用 vb6 代码创建一个 .dll。