Adding Characters to a string

From: Michael Bouchard (mbouchard_at_xNOSPAMx.ci.charlotte.nc.us)
Date: 06/30/04


Date: Wed, 30 Jun 2004 10:24:20 -0400

I am prompting technicians for a serial number at the begining of an install
and wanted to try to make sure that the serial number was formated
correctly.

The script below works but I am just wondering if there is a better way to
add the - to the string

Thanks,

Mike

CheckString = "565495423564898562124165"

If Len(CheckString) <> 29 then
  If Len(CheckString) = 24 then
    MyVar = Mid(CheckString,1,4)
    MyVar = MyVar & "-" & Mid(CheckString,5,4)
    MyVar = MyVar & "-" & Mid(CheckString,9,4)
    MyVar = MyVar & "-" & Mid(CheckString,13,4)
    MyVar = MyVar & "-" & Mid(CheckString,17,4)
    MyVar = MyVar & "-" & Mid(CheckString,21,4)
    Msgbox MyVar & vbcr & "5654-9542-3564-8985-6212-4165"
  Else
    'Something here
  End If
Else
  'Something here
End if



Relevant Pages