VBScript one line issue - Plz help a newbi

Discussion in 'Programming' started by miko67, Aug 16, 2007.

  1. #1
    I have this one line of vbscript:

     
    if len(mAccount)=15 then if mAccount(0)="8" Then mAccount=left(mAccount,4) & right(mAccount,10)
    
    Code (markup):
    I am wondering how it's supposed to look.

    The purpose of course, is to read a number, evaluate length = 15 and that the first digit is "8", then I want to remove the fifth digit.

    I get an error around the second "if"

    Help from a pro is appreciated :)
     
    miko67, Aug 16, 2007 IP
  2. Kuldeep1952

    Kuldeep1952 Active Member

    Messages:
    290
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    60
    #2
    Try replacing mAccount(0) with Mid(mAccount,1,1)

    The following should work:

    <%
    mAccount = "812305678912345"

    if (len(mAccount)=15 and Mid(mAccount,1,1)="8") Then
    mAccount=left(mAccount,4) & right(mAccount,10)
    end if

    response.write(mAccount)

    %>
     
    Kuldeep1952, Aug 16, 2007 IP
    miko67 likes this.
  3. miko67

    miko67 Well-Known Member

    Messages:
    769
    Likes Received:
    59
    Best Answers:
    0
    Trophy Points:
    120
    #3
    Very helpfull indeed. Thank you for taking the time.

    /miko67
     
    miko67, Aug 18, 2007 IP