reference for "trim" function and machine compatibility problem

sherong used Ask the Experts™
I did some VB code at home (with a Windows XP machine, running Visual Studio 6), compiled an exe file, everything worked fine. Tried the exe file on another Windows2000 machine (with VS6 installed), worked fine. (My user has a Windows 2000 machine.)

Sent the exe file to the user, it didn't work, poping up an error message saying stuff like "ActiveX can't create object". I figured he's missing some components that probably comes with VS6 installation? So I packaged my project with PDW, ended up with a 27M package. Post it online, get my user to download it, unzip and run setup, restart, still not working.

Then I sent all project files to my Windows2000 machine, hoping to package it there to make sure it's not operating system issue. Meanwhile I changed a little bit in the code, so I want to recompile first. But this machine gives me a compile error saying "cannot find library"! with the cursor pointing at a "Trim" function in my code. So maybe there's some reference I need to include in VB at this machine, but which one is for "trim" function? Please help! I pasted some of my code here, just in case anybody wants to see it. Also, if you have any idea on how to make it work on any other machine, please point out. Thanks a lot.

Private Sub menuOpen_Click()

Dim strOpenFile As String, fileExist As Boolean, i As Integer, openOk As Boolean
Dim fsoFile, mySplit, mySplitStr

fileExist = False
Set fsoFile = CreateObject("Scripting.FileSystemObject")

    CommonDialog2.Filter = "All Files (*.*)|*.*"
    strOpenFile = CommonDialog2.FileName
    If (Trim(strOpenFile) = "") Then Exit Sub
    If (fsoFile.fileExists(strOpenFile) = False) Then
        MsgBox ("File does not exist. Please select an existing file.")
        fileExist = True
    End If
Loop While fileExist = False


End Sub
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Trim is part of the VBA objects coming from C:\WINNT\System32\msvbvm60.dll


twalgrave, I don't understand, obviously I have included msvbvm60.dll in my project reference, it's the "Visual Basic for Applications" in the reference list, right? That's for sure checked.


twalgrave, I don't understand, obviously I have included msvbvm60.dll in my project reference, it's the "Visual Basic for Applications" in the reference list, right? That's for sure checked.
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

YEP.  I don't suspect you have a problem with the Trim function.  The only thing I can suspect from the code snippet provided is the Common Dialog Control.  Remove it from the project and re-add it (you'll have to remove the common dialog control on the form as well).

There is nothing wrong with the Trim function. Actually you are missing some other reference. Visual Basic does it often i.e. it points out some function telling that the reference is missing where as some other reference is missing. Just comment out the Trim function, you will be able to see that it's still giving the same error.

>ActiveX can't create object

Often this is caused by unregistered components.  Generally these are detected and registered with the PDW.

And Trim is an "intrinsic" function as pointed out above, so that wouldn't be the problem if the program runs at all.

FileSystemObject requires an extra dll.  This may not have been detected by the PDW because you late-bound it with CreateObject, which adds the component at run-time.

And I assume you have the common dialog control in the distribution (check the Setup.Lst file.)

Did you include the fso reference to the project?  If not, did you tell the PDW to include it and all of its dependencies?


twalgrave, I tried to remove the commondialog control and re-add it, nothing changed.

Bubla_m, I commented out the "trim" function, now it compiles okay! The openfile dialog box showed up and then it stopped at another "trim" code that I had in some other part to process the user-selected file?! Gee, I don't understand...

rspahitz, what reference does FileSystemObject need? Seems after I commented out the "trim" function in the above part, this part worked okay, so this would not be a problem caused by "fso"?

Anyway, here's my Setup.Lst file

SetupText=Copying Files, please stand by.

[Bootstrap Files]
File1=@VB6STKIT.DLL,$(WinSysPathSysFile),,,6-17-98 8:00:00 AM,102912,
File2=@COMCAT.DLL,$(WinSysPathSysFile),$(DLLSelfRegister),,5-30-98 8:00:00 AM,22288,4.71.1460.1
File3=@asycfilt.dll,$(WinSysPathSysFile),,,9-5-01 4:00:00 AM,77824,3.50.5014.0
File4=@olepro32.dll,$(WinSysPathSysFile),$(DLLSelfRegister),,9-5-01 4:00:00 AM,106496,5.0.5014.0
File5=@oleaut32.dll,$(WinSysPathSysFile),$(DLLSelfRegister),,9-5-01 4:00:00 AM,569344,3.50.5014.0
File6=@stdole2.tlb,$(WinSysPathSysFile),$(TLBRegister),,9-5-01 4:00:00 AM,17920,3.50.5014.0
File7=@msvbvm60.dll,$(WinSysPathSysFile),$(DLLSelfRegister),,9-5-01 4:00:00 AM,1388544,
File8=@MSVCRT40.DLL,$(WinSysPathSysFile),,,5-30-98 8:00:00 AM,326656,




[Setup1 Files]
File1=@MDAC_TYP.EXE,$(AppPath),,,6-25-98 8:00:00 AM,8124720,4.71.1015.0
File2=@MSSTDFMT.DLL,$(WinSysPath),$(DLLSelfRegister),$(Shared),6-17-98 8:00:00 AM,118784,
File3=@MSHFLXGD.OCX,$(WinSysPath),$(DLLSelfRegister),$(Shared),6-23-98 8:00:00 AM,407104,
File4=@MSADODC.OCX,$(WinSysPath),$(DLLSelfRegister),$(Shared),6-23-98 8:00:00 AM,118064,
File5=@COMCT332.OCX,$(WinSysPath),$(DLLSelfRegister),$(Shared),6-23-98 8:00:00 AM,369696,
File6=@MSDATLST.OCX,$(WinSysPath),$(DLLSelfRegister),$(Shared),6-23-98 8:00:00 AM,232248,
File7=@MSDATGRD.OCX,$(WinSysPath),$(DLLSelfRegister),$(Shared),6-23-98 8:00:00 AM,260920,
File8=@MSMASK32.OCX,$(WinSysPath),$(DLLSelfRegister),$(Shared),6-23-98 8:00:00 AM,166200,
File9=@MSCOMM32.OCX,$(WinSysPath),$(DLLSelfRegister),$(Shared),6-23-98 8:00:00 AM,103744,
File10=@SYSINFO.OCX,$(WinSysPath),$(DLLSelfRegister),$(Shared),6-23-98 8:00:00 AM,67376,
File11=@PICCLP32.OCX,$(WinSysPath),$(DLLSelfRegister),$(Shared),6-23-98 8:00:00 AM,82744,
File12=@MCI32.OCX,$(WinSysPath),$(DLLSelfRegister),$(Shared),6-23-98 8:00:00 AM,198456,
File13=@MSMAPI32.OCX,$(WinSysPath),$(DLLSelfRegister),$(Shared),6-23-98 8:00:00 AM,137000,
File14=@MSWINSCK.OCX,$(WinSysPath),$(DLLSelfRegister),$(Shared),6-23-98 8:00:00 AM,108336,
File15=@MSCHRT20.OCX,$(WinSysPath),$(DLLSelfRegister),$(Shared),6-25-98 8:00:00 AM,1008432,
File16=@RICHED32.DLL,$(WinSysPathSysFile),,,5-6-98 8:00:00 AM,174352,4.0.993.4
File17=@RICHTX32.OCX,$(WinSysPath),$(DLLSelfRegister),$(Shared),6-23-98 8:00:00 AM,203576,
File18=@MSINET.OCX,$(WinSysPath),$(DLLSelfRegister),$(Shared),6-23-98 8:00:00 AM,115016,
File19=@MSCOMCT2.OCX,$(WinSysPath),$(DLLSelfRegister),$(Shared),6-25-98 8:00:00 AM,644400,
File20=@MSCOMCTL.OCX,$(WinSysPath),$(DLLSelfRegister),$(Shared),6-25-98 8:00:00 AM,1062704,
File21=@COMDLG32.OCX,$(WinSysPath),$(DLLSelfRegister),$(Shared),5-6-99 9:00:00 AM,140288,
File22=@MSFLXGRD.OCX,$(WinSysPath),$(DLLSelfRegister),$(Shared),5-6-99 8:00:00 AM,244232,
File23=@TABCTL32.OCX,$(WinSysPath),$(DLLSelfRegister),$(Shared),6-23-98 8:00:00 AM,209192,
File24=@RDOCURS.DLL,$(WinSysPath),,$(Shared),6-17-98 8:00:00 AM,151552,
File25=@MSRDO20.DLL,$(WinSysPath),$(DLLSelfRegister),$(Shared),6-17-98 8:00:00 AM,393216,
File26=@MSRDC20.OCX,$(WinSysPath),$(DLLSelfRegister),$(Shared),6-22-98 8:00:00 AM,176440,
File27=@MSDBRPTR.DLL,$(WinSysPath),$(DLLSelfRegister),$(Shared),6-17-98 8:00:00 AM,299008,
File28=@msadox.dll,$(WinSysPath),$(DLLSelfRegister),$(Shared),9-5-01 4:00:00 AM,180224,2.70.7713.0
File29=@VB5DB.DLL,$(WinSysPath),,$(Shared),6-17-98 8:00:00 AM,89360,
File30=@MSREPL35.DLL,$(WinSysPathSysFile),,,4-24-98 3:40:20 AM,407312,3.51.623.0
File31=@msrd2x35.dll,$(WinSysPathSysFile),$(DLLSelfRegister),,4-24-98 3:40:20 AM,252176,3.51.623.0
File32=@expsrv.dll,$(WinSysPathSysFile),,,9-5-01 4:00:00 AM,379152,
File33=@vbajet32.dll,$(WinSysPathSysFile),,,9-5-01 4:00:00 AM,30992,
File34=@Msjint35.dll,$(WinSysPathSysFile),,,4-24-98 3:40:24 AM,123664,3.51.623.0
File35=@msjter35.dll,$(WinSysPathSysFile),,,4-24-98 3:40:20 AM,24848,3.51.623.0
File36=@msjet35.dll,$(WinSysPathSysFile),$(DLLSelfRegister),,4-12-99 8:00:00 AM,1046288,3.51.2723.0
File37=@DAO350.DLL,$(MSDAOPath),$(DLLSelfRegister),$(Shared),2-24-00 1:07:14 AM,570128,3.51.1608.0
File38=@MSBIND.DLL,$(WinSysPath),$(DLLSelfRegister),$(Shared),6-17-98 8:00:00 AM,77824,
File39=@msado20.tlb,$(WinSysPath),$(DLLSelfRegister),$(Shared),9-1-01 1:20:30 PM,61440,2.70.7713.0
File40=@MSDERUN.DLL,$(CommonFiles)\designer,$(DLLSelfRegister),$(Shared),6-8-98 8:00:00 AM,137216,
File41=@seqfilter.exe,$(AppPath),,,11-16-02 10:35:11 PM,118784,

To check whether you have the reference(for Trim) in your vb project

just write <Strings.> . It should show you the Trim function.

If it is then you should not have any problem.

This is not a solution but you can replace the Trim function with <Strings.Trim> and can check whether it is working or not.
I recommend re-installing VB.  If you are having a problem with the Trim function, either VB isn't correctly installed, or you have overwritten the VBA dll with another version that doesn't support Trim.


Bubla_m, I replaced all "Trim" with "Strings.Trim", and now the error messages pointing to "Trim" are all gone. And same error message pops up pointing to "Mid" function!! God, do I have to replace everything with <Strings.>? And, what the hell is wrong anyway? Aren't they supposed to be already included in standard VB environment?


twalgrave, yup, I guess this is the only thing I can do now. I'll reinstall this damn VB and see what happens.


Ok, I'm back, nothing changed with even the fresh installation of VS6! I gave up and replaced every "trim" with "strings.trim", also "mid" with "strings.mid". So now the compiler complained at "adox.catalog". I figured it's because I referenced to "Microsoft ADO ext. 2.7 for DDL ans Security" (msadox.dll) while I was coding on my XP machine, and my Windows2000 machine has only version 2.5.

What can I do now??? nuts...


Thanks god! Did some more search and digged out this piece: 

Christian d'Heureuse! You're my god! Now let's see if this version works on my user's machine...
go to project -> REFERENCES.  Make sure no item is labeled "MISSING"
Go to project -> references ->
U can see the following
Missing: Microsoft Access Data Objects 2.0 Library
Check that out
Click Ok
Now press Ctrl+F5
Thats the end of it
Good Luck...

I remember seeing a "missing trim" problem here at EE before.  I'll see if I can locate the link.  Maybe they found an answer.
Hey, here's a thought.  What if sherong's project has more than 1 reference that has a trim function.  That's probably why strings.trim works.  Fully qualified object references resolved the issue.


AzraSound and Crazy_king_in, yes I had one item labeled missing which was "ADO Ext. 2.7 for DDL and security", now that it's been replaced by "ADO Ext. 2.5 for DDL and security" (thanx to Christian d'Heureuse), nothing is missing now. Thanx for your inputs anyway.

twalgrave, actually I think you've got some points. I did have too many unnecessary references that I didn't bother to uncheck at the beginning. After double checked the references, I removed "Microsoft DAO 3.51 Object Library", "Microsoft Data Report Designer V6.0" and "Microsoft Data Formatting Object Library", and now my "trim" and "mid" function work fine!!!

I'm going to the client site this afternoon, I'll let you guys know if it works there.
I have had this problem before, and seen many people experience it.  It was always do to a missing reference, but, for some reason, it affected the string functions such as Trim and Mid.  Each time, there was a MISSING reference, and once removed, everything fell into place.


On second thought, yes, AzraSound, you're right. I believe the weird error for "trim" function did somehow originated from the missing reference. Just for testing, I added back the references to "DAO 3.51" etc., and my "trim" function still works, so it's not a problem caused by "more than 1 reference that has trim function"... Anyway, thanx for the input. I just wish it works on my client's machine. We'll see.


Good news! It worked!

Thanx a lot to all who contributed. AzraSound and Bubla_m, since both of you pointed out the reason being "missing" references, points will be splited to both of you. Please wait to receive your awards.

I have refunded half of the points for the question. Please accept one expert's comment as an answer and post another 50 pt question in this topic area with the title "points for <expert name> for the other expert to collect their points. Place the URL of the new question in this question so the other expert can find it easily. Thank you

CS Moderator

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial