Mobilize.Net Staff John Browne Posted April 19, 2021 Mobilize.Net Staff Report Share Posted April 19, 2021 Visual Basic supports a way to call external classes with the CreateObject() function. The function takes a class name as a parameter. Here's an example: Dim ExcelSheet As Object Set ExcelSheet = CreateObject("Excel.Sheet") In this case, the parameter for the function is a string literal ("Excel.Sheet") and the VBUC will migrate the VB6 code correctly. However... Suppose you have this VB6 code: Const XL = "Excel.Sheet" [some code] CreateObject(XL) In this case the VBUC will display the error "CreateObjects statements using a variable instead of a literal string" in the output code. This is because the value of the variable "foo" can change over time. In this case, it's advisable to replace the variable in the CreateObject syntax with the actual name of the object class being called: CreateObject(Excel.Sheet) Link to comment Share on other sites More sharing options...
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now