Link to home
Start Free TrialLog in
Avatar of carpachio
carpachio

asked on

incorrect reference for VBA in VB6

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
Avatar of Richie_Simonetti
Richie_Simonetti
Flag of Argentina image

hearing... (that's one of things that i hate from Microsoft)
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.
rspahitz, AFAIK, all string manipulations are done with fucntions exported by Visual Basic for Applications. (Check your Object Browser with F2, under string class)
carpachio, how did you do the project's "transfer"?
Avatar of carpachio
carpachio

ASKER

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
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.
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.
carpachio, right returns a variant data type, right$ returns a "pure" string.
...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.
rspahitz-

would opening a project in a different OS environment affect which VBA entry is selected?  
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.

ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
thanks Arthur and emoreau for your answers.  I didn't know the difference between right$ and right, and the "VBA." in front worked.
right returns a variant
right$ returns a string
emoreau, thanks for your last clarification :))