|
-
Nov 12th, 2000, 01:45 PM
#1
Thread Starter
Junior Member
I did the follow test code:
Code:
Option Explicit
Public Type Test
A As Integer
B As Integer
End Type
Dim Temp(1 To 10) As Test
Sub Main()
Dim I%
For I = 1 To 10
Temp(I).A = I
Next I
Call SearchInUDT(Temp().A)
End Sub
Private Sub SearchInUDT(Arr() As Variant)
Dim I%
For I = LBound(Arr) To UBound(Arr)
Debug.Print Arr(I)
Next I
End Sub
Basically what I want it to do is to pass an array of only A to the procedure.
So in the debug.print I would see:
1 2 3 4 5 6 7 8 9 10
I do know I can pass the whole UDT but what if I want to pass only one item of it (And in an array)?
VitalyB - VB6 Pro 
-
Nov 12th, 2000, 02:15 PM
#2
Thread Starter
Junior Member
Another example to the problem
Thought that first one was somewhat blurry so I wrote another example:
I have the following code in a module:
Code:
REM The UDT:
Type Temp
A as integer
B as integer
End Type
Dim TempArray(1 to 10) of Temp
REM: Now the following code:
Sub Main()
Dim I as Integer
For I = 1 to 10
TempArray(I).A=I
Next I
REM Now I want to print the array as a string with delimiters using the VB6 Join function:
Debug.Print Join(TempArray().A,",")
Now what I expect it to print in the debug window is: 1,2,3,4,5,6,7,8,9,10. However all I get is a "Invalid qualifier" Error. Can you tell me what's wrong and how I can do it right?
VitalyB - VB6 Pro 
-
Nov 12th, 2000, 03:41 PM
#3
transcendental analytic
1. You can't pass an UDT as a variant, neither arrays of them.
2. You can't Join an array of UDT's
You have to write your own procedure as you tried in the first sample, but instead pass it as an array of the udt type.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|