Link to home
Start Free TrialLog in
Avatar of sherong
sherong

asked on

reference for "trim" function and machine compatibility problem

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")

Do
    CommonDialog2.Filter = "All Files (*.*)|*.*"
    CommonDialog2.ShowOpen
    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.")
    Else
        fileExist = True
    End If
Loop While fileExist = False

OpenFasta

End Sub
Avatar of twalgrave
twalgrave

Trim is part of the VBA objects coming from C:\WINNT\System32\msvbvm60.dll


Avatar of sherong

ASKER

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.
Avatar of sherong

ASKER

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.
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).


ASKER CERTIFIED SOLUTION
Avatar of Bubla_m
Bubla_m

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
>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?
Avatar of sherong

ASKER

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

[Bootstrap]
SetupTitle=Install
SetupText=Copying Files, please stand by.
CabFile=seqfilter.CAB
Spawn=Setup1.exe
Uninstal=st6unst.exe
TmpDir=msftqws.pdw
Cabs=1

[Bootstrap Files]
File1=@VB6STKIT.DLL,$(WinSysPathSysFile),,,6-17-98 8:00:00 AM,102912,6.0.81.69
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,6.0.92.37
File8=@MSVCRT40.DLL,$(WinSysPathSysFile),,,5-30-98 8:00:00 AM,326656,4.21.0.0

[IconGroups]
Group0=SeqFilter
PrivateGroup0=True
Parent0=$(Programs)

[SeqFilter]
Icon1="seqfilter.exe"
Title1=SeqFilter
StartIn1=$(AppPath)

[Setup]
Title=SeqFilter
DefaultDir=$(ProgramFiles)\Project1
AppExe=seqfilter.exe
AppToUninstall=seqfilter.exe

[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,6.0.81.69
File3=@MSHFLXGD.OCX,$(WinSysPath),$(DLLSelfRegister),$(Shared),6-23-98 8:00:00 AM,407104,6.0.30.5
File4=@MSADODC.OCX,$(WinSysPath),$(DLLSelfRegister),$(Shared),6-23-98 8:00:00 AM,118064,6.0.81.71
File5=@COMCT332.OCX,$(WinSysPath),$(DLLSelfRegister),$(Shared),6-23-98 8:00:00 AM,369696,6.0.0.8169
File6=@MSDATLST.OCX,$(WinSysPath),$(DLLSelfRegister),$(Shared),6-23-98 8:00:00 AM,232248,6.0.81.69
File7=@MSDATGRD.OCX,$(WinSysPath),$(DLLSelfRegister),$(Shared),6-23-98 8:00:00 AM,260920,6.0.81.69
File8=@MSMASK32.OCX,$(WinSysPath),$(DLLSelfRegister),$(Shared),6-23-98 8:00:00 AM,166200,6.0.81.69
File9=@MSCOMM32.OCX,$(WinSysPath),$(DLLSelfRegister),$(Shared),6-23-98 8:00:00 AM,103744,6.0.81.69
File10=@SYSINFO.OCX,$(WinSysPath),$(DLLSelfRegister),$(Shared),6-23-98 8:00:00 AM,67376,6.0.81.69
File11=@PICCLP32.OCX,$(WinSysPath),$(DLLSelfRegister),$(Shared),6-23-98 8:00:00 AM,82744,6.0.81.69
File12=@MCI32.OCX,$(WinSysPath),$(DLLSelfRegister),$(Shared),6-23-98 8:00:00 AM,198456,6.0.81.69
File13=@MSMAPI32.OCX,$(WinSysPath),$(DLLSelfRegister),$(Shared),6-23-98 8:00:00 AM,137000,6.0.81.69
File14=@MSWINSCK.OCX,$(WinSysPath),$(DLLSelfRegister),$(Shared),6-23-98 8:00:00 AM,108336,6.0.81.69
File15=@MSCHRT20.OCX,$(WinSysPath),$(DLLSelfRegister),$(Shared),6-25-98 8:00:00 AM,1008432,6.0.81.77
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,6.0.81.69
File18=@MSINET.OCX,$(WinSysPath),$(DLLSelfRegister),$(Shared),6-23-98 8:00:00 AM,115016,6.0.81.69
File19=@MSCOMCT2.OCX,$(WinSysPath),$(DLLSelfRegister),$(Shared),6-25-98 8:00:00 AM,644400,6.0.81.77
File20=@MSCOMCTL.OCX,$(WinSysPath),$(DLLSelfRegister),$(Shared),6-25-98 8:00:00 AM,1062704,6.0.81.77
File21=@COMDLG32.OCX,$(WinSysPath),$(DLLSelfRegister),$(Shared),5-6-99 9:00:00 AM,140288,6.0.84.18
File22=@MSFLXGRD.OCX,$(WinSysPath),$(DLLSelfRegister),$(Shared),5-6-99 8:00:00 AM,244232,6.0.84.18
File23=@TABCTL32.OCX,$(WinSysPath),$(DLLSelfRegister),$(Shared),6-23-98 8:00:00 AM,209192,6.0.81.69
File24=@RDOCURS.DLL,$(WinSysPath),,$(Shared),6-17-98 8:00:00 AM,151552,5.0.81.69
File25=@MSRDO20.DLL,$(WinSysPath),$(DLLSelfRegister),$(Shared),6-17-98 8:00:00 AM,393216,6.0.81.69
File26=@MSRDC20.OCX,$(WinSysPath),$(DLLSelfRegister),$(Shared),6-22-98 8:00:00 AM,176440,6.0.81.69
File27=@MSDBRPTR.DLL,$(WinSysPath),$(DLLSelfRegister),$(Shared),6-17-98 8:00:00 AM,299008,6.0.81.69
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,6.0.81.69
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,6.0.0.8540
File33=@vbajet32.dll,$(WinSysPathSysFile),,,9-5-01 4:00:00 AM,30992,6.0.1.8268
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,6.0.81.69
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,6.0.0.3005
File41=@seqfilter.exe,$(AppPath),,,11-16-02 10:35:11 PM,118784,1.0.0.0
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.

Avatar of sherong

ASKER

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?
Avatar of sherong

ASKER

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

ASKER

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...
Avatar of sherong

ASKER

Thanks god! Did some more search and digged out this piece: http://www.inventec.ch/chdh/notes/11.htm 

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"
Cool.
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.
Avatar of sherong

ASKER

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.
Avatar of sherong

ASKER

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.
Avatar of sherong

ASKER

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.
sherong,

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

DigitalXtreme
CS Moderator
Experts-Exchange