473,396 Members | 1,826 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Using user-defined variables in excel vba DLL

Sourcode :
'


Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2.  
  3. Type CustomerInfo
  4.     company As String
  5.     contact As String
  6.     RegionCode As Integer
  7.     Sales As Long
  8. End Type
  9.  
  10. Type CountryInfo
  11.     CountryName As String
  12.     CountryCode As Integer
  13. End Type
  14.  
  15. Type Out_CustomerInfo
  16.     company As String
  17.     contact As String
  18.     RegionCode As Integer
  19.     Sales As Long
  20.     SalesStatus As String
  21. End Type
  22.  
  23.  
  24. Dim SalesStatus As String
  25.  
  26.  
  27.  
  28.  
  29. Sub main(
  30.  
  31. Dim Customers() As CustomerInfo
  32. 'Input
  33. Dim Out_Customers As Out_CustomerInfo
  34. 'Out
  35.  
  36. Dim Country As CountryInfo
  37. Dim MYSHEET As Object
  38. Dim i As Integer
  39. Dim m As Integer
  40. m = 3
  41. ReDim Customers(m) As CustomerInfo
  42.  
  43.  
  44. Set MYSHEET = ThisWorkbook.Worksheets("sheet1")
  45.  
  46. Customers(1).company = "Acme '
  47. Customers(1).contact = "Tim Robertson"
  48. Customers(1).RegionCode = 3
  49. Customers(1).Sales = 150677
  50.  
  51. Customers(2).company = "ALPHA"
  52. Customers(2).contact = "Dennie"
  53. Customers(2).RegionCode = 1
  54. Customers(2).Sales = 100
  55.  
  56. Country.CountryName = " Republic"
  57. Country.CountryCode = 6
  58.  
  59. ' DLL  Setting 
  60. Dim obj As Project1.Class1
  61. Set obj = New Project1.Class1
  62.  
  63.  
  64. For i = 1 To 2
  65.  
  66.  
  67. Out_Customers = obj.bb(Customers(), Country, i) 
  68.                         ' --- ERR  POINT
  69.  
  70.  
  71. MYSHEET.Cells(i, 1).Value = Out_Customers.company
  72. MYSHEET.Cells(i, 2).Value = Out_Customers.contact
  73. MYSHEET.Cells(i, 3).Value = Out_Customers.Sales
  74. MYSHEET.Cells(i, 4).Value = Out_Customers.SalesStatus
  75. Next i
  76.  
  77.  
  78.  
''Only user defined types defined in public object modules can be coerced to or from a variant or
passed to late-bound functions


Please let me know a solution
Jun 25 '12 #1
0 1402

Sign in to post your reply or Sign up for a free account.

Similar topics

16
by: Craig L | last post by:
I use ASP to obtain data from a database and I have a piece of javascript code I use on my website. I want to use the database variables in my javascript. I'm not very familiar with javascript, but...
2
by: Craig L | last post by:
This is a solution followup to a request for help posted on 11/04/03 at 12:51pm titled "Using ASP Variables". Here is how you can make ASP variables available for use in Javascript code. I hope you...
2
by: dana lees | last post by:
Hello, I am using session variables in a cs class file. I am inserting a sortedList to a session variable like this: System.Web.HttpContext.Current.Session = EventsSortedList; Later on,...
6
by: =?Utf-8?B?U2hhd24gU2VzbmE=?= | last post by:
Greetings! I was researching AJAX to provide a solution to displaying status messages while a long process executed. I found several examples online and was able to use their code to get a quick...
0
by: KIDDYLUMPR | last post by:
I am trying to send an email containing a file using vba in excel. Help!
3
by: skaushik | last post by:
Hi all, I ran an explain plan for a sql query which has some bind variables used in it. The plan shows that index is being used but the execution takes a very long time. Also, in another query the...
1
by: Keith Hughitt | last post by:
Hi all, I was wondering if anyone had any suggestions for alternative ways for multiple objects to keep track of a single variable? Initially, I thought of just using a single (YUI) Custom event...
8
by: adarshyam | last post by:
hi.. I am new to vb.net i am doing a program using dynamic textboxes which involves two pages .. where values of textboxes in one page must be transfered to to other sex of textboxes in another page,...
11
by: zanzo | last post by:
usually we create a url with parameters and values and send it via ajax to not loading page. Is there a way to not send variables in the url BUT using hidden variables?? I have a problem in my...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.