Solved

incorrect reference for VBA in VB6

Posted on 2002-07-08
16
585 Views
Last Modified: 2010-05-18
I wrote a vb6 app in a win2k environment and am now trying to transfer it over to a new winXP machine.  Somehow, the wrong VBA reference was selected.  Unfortunately there is no way to unselect it and select the correct one according to the help that pops up from msdn.  Is that really the case?  To be more specific I am unable to use all the string functions included in VBA, or at least not by the normal names, for example: right, space, etc.  Can i find out what the names are for the vba dll that is checked?

thanks
0
Comment
Question by:carpachio
  • 6
  • 4
  • 3
  • +2
16 Comments
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7138973
hearing... (that's one of things that i hate from Microsoft)
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 7138992
If I understand you correctly, you're wondering how to access functions such as right[$], space[$], etc.?

These are intrinsic functions and are included in the virtual machine: MSVBVM60.dll

I haven't tried any VB6 on XP yet, so I'm not sure of all the issues, but would be surprised if this aspect changes.

Can you describe your project?  Have you tried a simple test:

Create a form, add a button and a textbox and this code:

Private Sub Command1_Click()
  dim strX as string

  strX="This is a test"
  text1.text = right$(strX,4) & space$(3) & left$(strX,4)
end sub

Run and click the button to see if "test   This" appears in the textbox.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7139007
rspahitz, AFAIK, all string manipulations are done with fucntions exported by Visual Basic for Applications. (Check your Object Browser with F2, under string class)
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7139009
carpachio, how did you do the project's "transfer"?
0
 

Author Comment

by:carpachio
ID: 7139019
to clarify

I'm not using:
text1.text = right$(strX,4) & space$(3) & left$(strX,4)

I'm using:
text1.text = right(strX,4) & space(3) & left(strX,4)

I think that there are a couple of different dll files which contain the vba functions like these, and possibly the one which is selected currently uses the "right$" command as opposed to just simply "right".  Also, I didn't really transfer the project at all, rather I'm just trying to get it to run under XP.  Hopefully this makes sense.  Essentially, what I need to find out is how to unselect the reference to VBA which is currently selected in the projects references and select a different VBA reference.

thanks
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 7139027
Richie, if I go to the object browser and find the "strings" class, I see it is a member of the VBA library which is the VBA libarary:

"Function String(Number As Long, Character)
"    Member of VBA.Strings
"    Returns a repeating character string of the length specified"

"Module Strings
"    Member of VBA
"    Procedures used to perform string operations"

"Library VBA
"    C:\WINNT\SYSTEM32\MSVBVM60.dll
"    Visual Basic For Applications"

I don't know that this specifically helps, but it at least shows that this class is embedded in the VB6 virtual machine.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7139047
OK. But as you use VBA in office apps, it doesn't references to MSVBVM60.dll.
To me, Virtual Machine get those from vba6.dll and exports them to VB IDE, but maybe i am wrong.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7139050
carpachio, right returns a variant data type, right$ returns a "pure" string.
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 22

Expert Comment

by:rspahitz
ID: 7139177
...and I don't know of any way to unreference the VBA engine from VB...

Going back to your original question: "...the wrong VBA reference was selected..."

How was this selected?  As far as I know, VB6 selects this automatically when you open a new project, and it is an integral part of the project.

--
Richie, after re-reading the Q, I think we're both a bit confused by the VBA reference.  Since carpachio stated, "I wrote a vb6 app," I'm suspecting that the VBA issue is related to the VBA entry that appears when you examine a VB6 project's references.
0
 

Author Comment

by:carpachio
ID: 7139181
rspahitz-

would opening a project in a different OS environment affect which VBA entry is selected?  
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 7139191
I've tried it in Win98, WinNT, and Win2000, and they all bring up MSVBVM60.dll, but I think they have slight variations (possibly depending on the service pack.)

On my Win2000/VB6SP3 install (C:\WINNT\system32), my file is 1,356K, 8/23/2001 6:00am.  What does yours show?  It may be worth while to go to the Microsoft website and see what they have for this under their download section.

0
 
LVL 69

Accepted Solution

by:
Éric Moreau earned 200 total points
ID: 7139229
I have met this situation a couple of time (Mid, Left, Right, ... function not recognized). Use "VBA." in fromt of all your function and it will work.
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 7140413
as for the problem of Right, Left etc not being "found", that USUALLY is the signature of a MISSING REFERENCE elsewhere in the Project/References choices.  Look for other references that are marked as MISSING.

Carpachio: on antoher note, when you say
"I'm not using:
text1.text = right$(strX,4) & space$(3) & left$(strX,4)

I'm using:
text1.text = right(strX,4) & space(3) & left(strX,4)"

those are the WRONG versions of the functions to be using.  You should be using Right$, Left$ and Space$

as they will return STRING values (you are concatenating the values and then assigning the result to Text1.Text, which is a STRING.

As you are currently writing the code, the values are combined as VARIANTs, and the reuslting VARIANT is then CONVERTED to a STRING before it is assigned to Text1.Text - This requires additional processing time, and is generally NOT a godd idea.

Arthur Wood
0
 

Author Comment

by:carpachio
ID: 7140811
thanks Arthur and emoreau for your answers.  I didn't know the difference between right$ and right, and the "VBA." in front worked.
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 7140936
right returns a variant
right$ returns a string
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7142021
emoreau, thanks for your last clarification :))
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now