Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 600
  • Last Modified:

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
0
carpachio
Asked:
carpachio
  • 6
  • 4
  • 3
  • +2
1 Solution
 
Richie_SimonettiCommented:
hearing... (that's one of things that i hate from Microsoft)
0
 
rspahitzCommented:
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
 
Richie_SimonettiCommented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Richie_SimonettiCommented:
carpachio, how did you do the project's "transfer"?
0
 
carpachioAuthor Commented:
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
 
rspahitzCommented:
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
 
Richie_SimonettiCommented:
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
 
Richie_SimonettiCommented:
carpachio, right returns a variant data type, right$ returns a "pure" string.
0
 
rspahitzCommented:
...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
 
carpachioAuthor Commented:
rspahitz-

would opening a project in a different OS environment affect which VBA entry is selected?  
0
 
rspahitzCommented:
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
 
Éric MoreauSenior .Net ConsultantCommented:
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
 
Arthur_WoodCommented:
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
 
carpachioAuthor Commented:
thanks Arthur and emoreau for your answers.  I didn't know the difference between right$ and right, and the "VBA." in front worked.
0
 
Éric MoreauSenior .Net ConsultantCommented:
right returns a variant
right$ returns a string
0
 
Richie_SimonettiCommented:
emoreau, thanks for your last clarification :))
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 6
  • 4
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now