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 84
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.
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

LVL 84

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

730 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