Results 1 to 4 of 4

Thread: MID()/MID$(), FORMAT() alternatives

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2006
    Posts
    40

    MID()/MID$(), FORMAT() alternatives

    Hi, im using VB4 (i know...) and i would like to use similar functions to Mid()/Mid()$ and Format() without using those specific functions. The reason for this is that those functions are causing probleme when I dont have the proper references to Excel library.

    all in all...are there any pure VB function that do the same job without anoying me with object librairies?

    BTW Round() doesnt seem to exist in VB4...

    TIA

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: MID()/MID$(), FORMAT() alternatives

    If you experience something like "cannot find library or..." error in VB IDE then it's not Excel - it's known bug in VB since forever...
    The problem if that it somehow manages to "loose" refernces to one of its core component - VBA library which contains all string, numeric, etc functions.
    Coincidentally all of MS Office applications also use it.
    The fix is to do one of the following:

    - type VBA. (including the ".") in front of say Mid, Left, Right...
    - or rebuild you project by creating a brand new one and adding all of your existing objects from the "bad" one.

    However, if that is not what you experience then please describe your problem with more details.

  3. #3
    Fanatic Member bgmacaw's Avatar
    Join Date
    Mar 2007
    Location
    Atlanta, GA USA
    Posts
    524

    Re: MID()/MID$(), FORMAT() alternatives

    Mid and Format are core VB language functions so you shouldn't have to have any reference to Excel unless something is messed up somewhere.

    One place where things can be messed up is in the references. Open your references dialog and make sure that the Visual Basic objects and procedures are checked and at the top of the priority list. I've seen this setting get confused sometimes.

    If you've installed a newer version of Office this might have also screwed up your references. I've seen this happen in some cases. This can be hard to fix without re-installing VB.

    Round didn't make the scene until VB6 as I recall. However, CInt and other conversion functions will do the same "banker's rounding" job.

    Of course, I'd recommend just scrapping VB4 and going to VB.NET Express 2005 (which is free, BTW) unless you've got a very compelling reason to use VB4.

  4. #4
    Head Hunted anhn's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    3,669

    Re: MID()/MID$(), FORMAT() alternatives

    This is a common problem with misleading error message from VB/VBA.

    When a library is MISSING, all core functions fail as well.

    Particularly if working with different versions of an Office app. such as Excel, with early binding to, say, Excel 11.0, but user uses Excel 9.0 then it will cause problem of MISSING library.
    In this case, later binding need to be used.

    I dealed with this problem many times as in my company sometimes we have 2 or 3 different versions of Excel.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width