Author Topic: Mid ASP String Function  (Read 4914 times)

Offline admin

  • Administrator
  • Sr. Member
  • *****
  • Posts: 296
    • View Profile
Mid ASP String Function
« on: December 20, 2009, 03:05:27 PM »
Mid is a commonly used ASP function that allows you to extract characters from the center of a string.

Let's say you have a phone number that is always XXX-XXX-XXXX. You need to get just the middle three digits to run a comparison. You could do:
MiddlePart = Mid(TelNumber, 5, 3)

The first parameter is the string you want to examine. The second number is the starting point, and the third number is the number of characters you want to get. The function returns a string.

If you put in

TelNumber = 123-456-7890

Then

MiddlePart = Mid(TelNumber), 5, 3)

Would have MiddlePart set equal to 456.