Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I create a function that will bring back a variant ?

Status
Not open for further replies.

bigracefan

Programmer
Apr 2, 2002
304
US
I have created a class that I'm using to read a file. I'm at the point where I want to read the comma dilimitted text file and then bring the results into my main form as a variant. Any ideas or should I be trying something else?

Thanks,

Pete
 
From your Form...
[tt]
Set mObjectDLL = CreatObject("MyDLL.Functions")
strReturnText = mmObjectDLL.ReadFile
[/tt]

In your Class...

Public Fuunction ReadFile() as Variant

.... Do your stuff....

ReadFile = varStuffToSendBack
End Function

Craig

"I feel sorry for people who don't drink. When they wake up in the morning, that's as good as they're going to feel all day."
~Frank Sinatra
 
How do I set the varStuffToSendBack part?

Say I'm bringing back something like

for x = 0 to MaxLines
field1(x) = stuffA
field2(x) = stuffB
field3(x) = stuffC
Next

This is the part that I'm having a problem with. How do I associate the field(x)'s with the VarStuffToSendBack.

Thanks.

Pete
 
not exactly sure what you are up to, but taking a guess . .
use 2 public functions in the DLL

1st function
public function readFile(thepath as string) as long
code . . . .
opens the file
redims and populates arrays Fieldx(Index)
returns the number of records read
end function

2nd function(s)
public function readFieldx(Index as long) as variant
if Index > ubound(Fieldx) then
readFieldx = "" . . . . or 0 or whatever . .
else
readFieldx = Fieldx(Index)
endif
end function



in whatever application calls the DLL:
run the first function and use the result to set up
the if/next loop containing the 2nd function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top