I am looking for help on a better way of foramtting a MAC address.

Another application tracks the MAC addresses in a file and the fomrat is as
follows:00A0F84B51FF

Now that security want us to make changes I need to add MAC addresses in a
access list as: 00:A0:F8:4B:51:FF. I need to have the colons like a standard
MAC format.

I wrote the script that gets a list of all the mac addresses but of course
not in the format I need. I know that I could use the mid vbscript command
and break up the string and store in variables and manipulate the string how
I need.

I am asking is there a better way to reformat the MAC address with the
colons.I know that every two numbers a colon will need to be placed.

Any suggestions?

Re: mac address format by James

James
Thu Jan 26 17:08:31 CST 2006

"Big D" <BigDaddy@newsgroup.nospam> wrote in message
news:%23X0SEkqIGHA.3176@TK2MSFTNGP12.phx.gbl...
> I am looking for help on a better way of foramtting a MAC address.
>
> Another application tracks the MAC addresses in a file and the fomrat is
as
> follows:00A0F84B51FF
>
> Now that security want us to make changes I need to add MAC addresses in a
> access list as: 00:A0:F8:4B:51:FF. I need to have the colons like a
standard
> MAC format.
>
> I wrote the script that gets a list of all the mac addresses but of course
> not in the format I need. I know that I could use the mid vbscript command
> and break up the string and store in variables and manipulate the string
how
> I need.
>
> I am asking is there a better way to reformat the MAC address with the
> colons.I know that every two numbers a colon will need to be placed.
>
> Any suggestions?

You could use a regular expression inside of a function.

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
MsgBox FormatMAC("00A0F84B51FF")
MsgBox FormatMAC("00 A0 F8 4B 51 FF")
MsgBox FormatMAC("00-A0-F8-4B-51-FF")
MsgBox FormatMAC("00:A0:F8:4B:51:FF")
MsgBox FormatMAC("Your MAC address is 00A0F84B51FF")

Function FormatMAC(sMAC)
Dim oRegEx
Set oRegEx = CreateObject("VBScript.RegExp")
oRegEx.Pattern = "([\dA-F]{2}).?([\dA-F]{2}).?([\dA-F]" _
& "{2}).?([\dA-F]{2}).?([\dA-F]{2}).?([\dA-F]{2})"
FormatMAC = oRegEx.Replace(sMAC, "$1:$2:$3:$4:$5:$6")
End Function
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



Re: mac address format by Big

Big
Fri Jan 27 06:23:53 CST 2006

Thanks for your help. This helped and avoided using multiple mid statements.


"James Whitlow" <jameswhitlow@spamcop.net> wrote in message
news:uDkNu1sIGHA.1876@TK2MSFTNGP11.phx.gbl...
> "Big D" <BigDaddy@newsgroup.nospam> wrote in message
> news:%23X0SEkqIGHA.3176@TK2MSFTNGP12.phx.gbl...
>> I am looking for help on a better way of foramtting a MAC address.
>>
>> Another application tracks the MAC addresses in a file and the fomrat is
> as
>> follows:00A0F84B51FF
>>
>> Now that security want us to make changes I need to add MAC addresses in
>> a
>> access list as: 00:A0:F8:4B:51:FF. I need to have the colons like a
> standard
>> MAC format.
>>
>> I wrote the script that gets a list of all the mac addresses but of
>> course
>> not in the format I need. I know that I could use the mid vbscript
>> command
>> and break up the string and store in variables and manipulate the string
> how
>> I need.
>>
>> I am asking is there a better way to reformat the MAC address with the
>> colons.I know that every two numbers a colon will need to be placed.
>>
>> Any suggestions?
>
> You could use a regular expression inside of a function.
>
> '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> MsgBox FormatMAC("00A0F84B51FF")
> MsgBox FormatMAC("00 A0 F8 4B 51 FF")
> MsgBox FormatMAC("00-A0-F8-4B-51-FF")
> MsgBox FormatMAC("00:A0:F8:4B:51:FF")
> MsgBox FormatMAC("Your MAC address is 00A0F84B51FF")
>
> Function FormatMAC(sMAC)
> Dim oRegEx
> Set oRegEx = CreateObject("VBScript.RegExp")
> oRegEx.Pattern = "([\dA-F]{2}).?([\dA-F]{2}).?([\dA-F]" _
> & "{2}).?([\dA-F]{2}).?([\dA-F]{2}).?([\dA-F]{2})"
> FormatMAC = oRegEx.Replace(sMAC, "$1:$2:$3:$4:$5:$6")
> End Function
> '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>