vb6-migration

This Code works VB but gives exception in VB.NET, Why?

馋奶兔 提交于 2019-12-11 12:38:07
问题 Aim to achieve : I want to change the SourceData of the Pivot table. I want to change it from 'C:\[file.xlsx]SheetName'!RangeName to 'SheetName'!RangeName I have the following implementation : For Each table In sheet.PivotTables Dim str = "'" + Split(table.SourceData, "]")(1) table.SourceData = str // Gives Exception here Next table // Exception: Exception from HRESULT: 0x800A03EC At the time of error str has value 'SheetName'!RangeName (This is fine.. ) I am also getting a message box before

accessing multiple form controls using a variable for the name

末鹿安然 提交于 2019-12-11 03:22:39
问题 I'm trying to iterate through a group of ComboBoxes and set a property using a concatenated string & variable to represent the name of the control. However, I can't get the instance of the form to recognize the (String & Integer_Variable) as one of its controls -- and so it doesn't recognize any of the appropriate properties or subroutines as members of the System.Windows.Forms.Control. I found the DirectCast solution on SO and it appears to work (although I'm dubious), but that feels like a

Why would one declare both a Let and Set property accessor in VB6

偶尔善良 提交于 2019-12-10 17:57:51
问题 In an older project I found a property declaration in a class module which looks like the following... Public Property Get DrawObject() As Object Set DrawObject = m_obj End Property Public Property Let DrawObject(obj As Object) Set m_obj = obj Draw End Property Public Property Set DrawObject(obj As Object) Set m_obj = obj Draw End Property I would like to know why the DrawObject property has both a Let and Set accessor defined; what could be the purpose of such a declaration? 回答1: The only

Performance of passing data between .Net and COM assemblies

喜欢而已 提交于 2019-12-10 10:18:09
问题 I am in the process of migrating a legacy VB6 app to .Net, however since it is a high-profile business critical application, it is being done piece by piece. In the interest of improving performance, there is one method which gets hit a lot,thousands of times during the application life, and I was wanting to rewrite it in .Net (C#) to see if the runtime can be improved. The method in question manipulates ADODB Recordsets. Is there any performance issues I should be aware of or take into

VB.net Passing a structure to unmanaged dll

空扰寡人 提交于 2019-12-09 19:25:52
问题 I'm migrating some VB6 code to VB.net, the code contains a structure that contains 1d arrays, 2d arrays, and few other variables. The general outline of the Vb.net structure is as under Public Structure Test Dim a As Single Dim b As Single Dim c As Single <VBFixedArray(2)> Dim arr1() As Single <VBFixedArray(2, 2)> Dim mdarr1(,) As Single <VBFixedArray(4)> Dim arr2() As Byte <VBFixedArray(4)> Dim arr3() As Short <VBFixedArray(3, 2)> Dim mdarr2(,) As Integer Dim d As Integer Dim e As Decimal

Implications of “Public Shared” Sub / Function in VB

百般思念 提交于 2019-12-08 18:43:39
问题 Can anyone explain me in VB i need to use Public Shared Sub so it can be accessed from another form. But what this "Public" and "Shared" means? Who is public ? With who is shared ? If it is public shared does this means some other software or "some hacker app" can easier have access to this sub and it's values? 回答1: In VB.NET, Shared is equivalent to static in C# - meaning the member belongs to the class, not an instance of it. You might think that this member is 'Shared' among all instances,

System.TypeLoadException: Could not load type 'x' from assembly 'y'

元气小坏坏 提交于 2019-12-08 08:42:43
问题 I am trying to port a program from VB6 to C# that reads in a binary file and parses it. I get no compile time errors or warnings however when I try to run it, before it even enters Main() it throws the exception System.TypeLoadException was unhandled Message=Could not load type 'Conversion.DataStructures.ClientOld' from assembly 'SandboxConsole, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' because it contains an object field at offset 1 that is incorrectly aligned or overlapped by a

How can I adapt a 32-bit VB6 application to work with 64-bit Office?

谁说胖子不能爱 提交于 2019-12-07 16:11:42
问题 I have an application developed in VB 6.0 and VBA that uses latest Office 32 bit version. But since this application is 32 bit, it does not run on systems where 64 bit Office versions are installed. What is the best strategy I have to adopt to port this application to 64 bit. We have a mandate to use VB.NET and minimal (as much as possible) code modification from VB/VBA to .NET 64 bit. Please suggest the best option I can use so that I can leverage all best practices for this porting. 回答1:

Convert VB6 Scripting.Dictionary to .NET Generic Dictionary

a 夏天 提交于 2019-12-06 14:30:14
Currently im working on wrapping and converting some old VB6 code to .NET and i need to be able to use the scripting.dictionary returned by huge old price of VB6 code. I want to convert this to the .NET generic Dictionary(Of TKey, TValue) The solution is to write an extension method for scripting.dictionary to convert to a .net Dictionary(Of TKey, TValue) VB.NET <Extension()> Public Function ToDictionary(Of T, T2)(dic As Scripting.Dictionary) As Dictionary(Of T, T2) Return dic.Cast(Of Object)().ToDictionary(Function(i) CType(i, T), Function(i) CType(dic.Item(i), T2)) End Function C#.NET

VB6 Manifest not working on Windows 7

放肆的年华 提交于 2019-12-06 05:38:46
问题 I have created a manifest file for a VB6 application that is running on Windows 7 (not for any visual style changes, just to make sure it accesses the common registry and not a virtualised one) The exe name is Capadm40.exe, the manifest is named Capadm40.exe.manifest and contains the following: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <assemblyIdentity version="1.0.0.0" processorArchitecture="X86" name=