#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default syntax

What is the syntax for transfering the value of a varible
in VB6 into VBA, so I can use it in Excel. strQtNum has
been DIM'd in VBA. We can Import Databases, but variables
I do not know.

Thanks.
Don
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 811
Default syntax

"Don" wrote in message
...
What is the syntax for transfering the value of a varible
in VB6 into VBA, so I can use it in Excel. strQtNum has
been DIM'd in VBA. We can Import Databases, but variables
I do not know.


Hi Don,

Two ways I can think of right off the bat.

1) Have your VB6 DLL or EXE write the value of the variable to a known cell
in a worksheet of an open workbook on the Excel side and then have VBA read
the value of the variable from that cell.

2) If you have a class within your VB6 DLL or EXE that VBA has a reference
to, add a Property procedure to that class that returns the value of the
variable. Then have VBA call that property of the class to retrieve the
variable's value.

If you'd like more detail on how to implement either of these methods,
post back with a bit more detail on exactly what the relationship is between
Excel and VB6 in your project and I'll be glad to help you out.

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default syntax

Variables in VBA follow the same scope and lifetime restrictions as
variables in VB6. So you couldn't create a variable in Excel unless you use
the VBA extensibility library and declared it, then wrote code to initialize
it and executed the code.

Perhaps there is a workaround if you could be more specific about what you
want to do. Are you trying to run a macro and to pass it a variable value.

in a VBA General Module

Public gMyVar as Long

Public Sub SetMyVar(myVal)
gMyVar = myVal
End Sub

Public Function MyVar()
Application.Volatile
myVar = gMyVar
End Sub

in VB6

someVar = 21
xlApp.Run "MyWorkbook.xls!SetMyVar", someVar


A worksheet could use a formula

=Sum(A1:B9,MyVar())

--
Regards,
Tom Ogilvy



Don wrote in message
...
What is the syntax for transfering the value of a varible
in VB6 into VBA, so I can use it in Excel. strQtNum has
been DIM'd in VBA. We can Import Databases, but variables
I do not know.

Thanks.
Don



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
IF, THEN SYNTAX BBABBZZ Excel Worksheet Functions 5 January 12th 10 10:11 PM
VB Syntax dhstein Excel Discussion (Misc queries) 6 November 8th 08 09:13 PM
Syntax HELP Eric H Excel Discussion (Misc queries) 4 August 30th 08 01:30 AM
VBA syntax Sunantoro Excel Discussion (Misc queries) 1 September 21st 05 03:19 AM
If then syntax RL Excel Worksheet Functions 3 June 22nd 05 05:30 AM


All times are GMT +1. The time now is 01:50 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"