Reguar Expression in a Module

Posted on 2004-08-27
Last Modified: 2012-06-27

How do I create a regular expresion like I can do in VBs aswell?
Question by:DaFou
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
LVL 85
ID: 11912707
You need to set a reference to the Microsoft VBScript Regular Expressions 5.5 (the latest version), then do the same thing as you would in VB:

Dim varRegex As Regex

and use it to do whatever. Note, however, that RegExs are not specifically supported in VBA, and if you intend to distribute this to end users you'll end up with trouble when attempting to reference this ... notice that when you set this reference, the "location" specified ends with a number 3 ... this is the "entry point" into the dll that parses regular expressions, and if you simply distribute your db to others, you'll find that this reference will NOT transfer over in every case ... why this is I don't know, but I had this bite me a year or so back.

Author Comment

ID: 11912762
where do i find the .dll and how can i distribute it?
LVL 44

Expert Comment

ID: 11912769
Every MDB file can associate with a module if one is created. In database view click on modules. If one has been created, you will see it named here. Else click on New and you can create a new one. The module can contain subroutines and functions. Here you declare a function or subroutine, dimension any variables used in the routine and add the code to accomplish the intent of the sub or function. There is a lot of help in VB help on these matters. You can get to the VB Editor by typing Ctl-G or Alt-F11. Here you will see the code window and the Immediate Pane in which you can test various code snippets as you develop your code. Hope this helps.
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

LVL 85

Accepted Solution

Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 11912955
You don't install JUST vbscript ... you have to install the entire Windows Scripting Host (WSH) which is pretty invasive. Of course, any machine with IE on it has the necessary dll files, so you could hedge your bets and assume that the user hasn't "unregistered" this ... other problems include admins turning off execution of VBScripts, anti-viruse programs that will "catch" your vbscript, etc etc ... and, as I said, RegExs aren't directly supported in VB/VBA, therefore you're working in uncharted territory ... this isn't to say programmers don't do this, just that it's not supported.

FWIW there is a component that claims to mimci the functions of Regular Expressions:

Author Comment

ID: 12113392
WHat to do if I have MS IE 6.0 installed but Microsoft VBScript Regular Expressions 5.5.dll does nto show up in my references?


Author Comment

ID: 12857824
what? this is evil. this questin has not been answerd and abandoned by the experts not me.....
totally unaceptable by principle. how about opening this question up again and this guys you gave the points can keep the points. also you can take extra points from me to reopen this question

Author Comment

ID: 12858064
ok sounds fair enough, I must have missed those 4 days warning due to fault of my own. never mind then :-)

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question