a two dimensional array question

Discussion in 'ASP General' started by c676228, Feb 3, 2007.

  1. c676228

    c676228 Guest

    Hi all,
    I have a strange question which I cannot figure that out myself.
    I tried to escape some apostrophe in the name string.
    Function PrepCustomerDatatoArray(iTotNumCustomer)
    dim CustInfoArr(50, 5)
    ....
    for i=1 to iTotNumCustomer

    If InStr(FName, "'") <> 0 Then
    CustInfoArr(i-1, 0)=EscStrApostrophe(FName) ' B'etty will become B''etty
    Else
    CustInfoArr(i-1, 0)=FName
    End If
    Response.Write CustInfoArr(i-1, 0) & "<br>" ' It displayed B''etty
    If MInit<> "" Then
    CustInfoArr(i-1, 1)=MInit
    End If
    If InStr(LName, "'") <> 0 Then
    CustInfoArr(i-1, 2)=EscStrApostrophe(LName)
    Else
    CustInfoArr(i-1, 2)=LName
    End If
    Response.Write CustInfoArr(i-1, 2) & "<br>" ' It displayed O''neal if
    customer enter O'neal as last name
    CustInfoArr(i-1, 3)=BDate

    Next
    'but here it what strange thing happened
    'the fname and lname in array with apostrophe will become empty here
    'but it display MInit and BirthDate OK
    'if fields don't have apostrophe, it will be displayed fine
    'what is going on the array is in the scope since mInit and bDate are fine
    and if
    'no apostrophe, everything is fine?
    For i=1 to iTotNumInsured
    Response.Write CustInfoArr(i-1, 0) & " " & CustInfoArr(i-1, 1) & " " &
    CustInfoArr(i-1, 2) & " " & CustInfoArr(i-1, 3)
    Next
    End Function
    --
    Betty
    c676228, Feb 3, 2007
    #1
    1. Advertising

  2. Hi Betty,

    Would you please also post the code in EscStrApostrophe() here? This may
    help us find the problem. Also, I suggest you may test with this: Replace
    following code:

    If InStr(FName, "'") <> 0 Then
    CustInfoArr(i-1, 0)=EscStrApostrophe(FName) ' B'etty will become B''etty
    Else
    CustInfoArr(i-1, 0)=FName
    End If

    With

    CustInfoArr(i-1, 0)=FName

    This won't call EscStrApostrophe() so we can check if this is the problem.

    Sincerely,

    Luke Zhang

    Microsoft Online Community Support
    ==================================================
    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    ications.

    Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 1 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions or complex
    project analysis and dump analysis issues. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/subscriptions/support/default.aspx.
    ==================================================

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Luke Zhang [MSFT], Feb 5, 2007
    #2
    1. Advertising

  3. c676228

    c676228 Guest

    Hi Luke,
    Here is the function:

    Function EscStrApostrophe(ByVal Str)
    dim NameArr
    dim NameStr
    NameStr=""
    NameArr=Split(Str, "'", -1)
    For i=0 to UBound(NameArr)
    NameStr=NameStr & NameArr(i) & "''"
    Next
    EscStrApostrophe=Left(NameStr, Len(NameStr)-2)
    End Function
    --
    Betty


    "Luke Zhang [MSFT]" wrote:

    > Hi Betty,
    >
    > Would you please also post the code in EscStrApostrophe() here? This may
    > help us find the problem. Also, I suggest you may test with this: Replace
    > following code:
    >
    > If InStr(FName, "'") <> 0 Then
    > CustInfoArr(i-1, 0)=EscStrApostrophe(FName) ' B'etty will become B''etty
    > Else
    > CustInfoArr(i-1, 0)=FName
    > End If
    >
    > With
    >
    > CustInfoArr(i-1, 0)=FName
    >
    > This won't call EscStrApostrophe() so we can check if this is the problem.
    >
    > Sincerely,
    >
    > Luke Zhang
    >
    > Microsoft Online Community Support
    > ==================================================
    > Get notification to my posts through email? Please refer to
    > http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    > ications.
    >
    > Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    > where an initial response from the community or a Microsoft Support
    > Engineer within 1 business day is acceptable. Please note that each follow
    > up response may take approximately 2 business days as the support
    > professional working with you may need further investigation to reach the
    > most efficient resolution. The offering is not appropriate for situations
    > that require urgent, real-time or phone-based interactions or complex
    > project analysis and dump analysis issues. Issues of this nature are best
    > handled working with a dedicated Microsoft Support Engineer by contacting
    > Microsoft Customer Support Services (CSS) at
    > http://msdn.microsoft.com/subscriptions/support/default.aspx.
    > ==================================================
    >
    > This posting is provided "AS IS" with no warranties, and confers no rights.
    >
    >
    >
    >
    c676228, Feb 5, 2007
    #3
  4. Hi Betty,

    Thank you for the code. I tested it and didn't find any issues with it.
    Anyway, I suggets you may try following code instead:

    CustInfoArr(i-1, 0)=EscStrApostrophe(FName) ' B'etty will become B''etty
    Else
    CustInfoArr(i-1, 0)=FName
    End If

    with

    CustInfoArr(i-1, 0)=replace(FName,"'","''")

    The replace method can help us replace ' with ".

    And, I also suggest you may debug in these code in Visua Interdev to see if
    the passed parameters are empty, since we get no output, and the code is
    correct.

    Sincerely,

    Luke Zhang

    Microsoft Online Community Support
    ==================================================
    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    ications.

    Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 1 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions or complex
    project analysis and dump analysis issues. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/subscriptions/support/default.aspx.
    ==================================================

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Luke Zhang [MSFT], Feb 6, 2007
    #4
  5. c676228

    c676228 Guest

    Luke,
    Thank you for that. It should works. I appreciated
    --
    Betty


    "Luke Zhang [MSFT]" wrote:

    > Hi Betty,
    >
    > Thank you for the code. I tested it and didn't find any issues with it.
    > Anyway, I suggets you may try following code instead:
    >
    > CustInfoArr(i-1, 0)=EscStrApostrophe(FName) ' B'etty will become B''etty
    > Else
    > CustInfoArr(i-1, 0)=FName
    > End If
    >
    > with
    >
    > CustInfoArr(i-1, 0)=replace(FName,"'","''")
    >
    > The replace method can help us replace ' with ".
    >
    > And, I also suggest you may debug in these code in Visua Interdev to see if
    > the passed parameters are empty, since we get no output, and the code is
    > correct.
    >
    > Sincerely,
    >
    > Luke Zhang
    >
    > Microsoft Online Community Support
    > ==================================================
    > Get notification to my posts through email? Please refer to
    > http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    > ications.
    >
    > Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    > where an initial response from the community or a Microsoft Support
    > Engineer within 1 business day is acceptable. Please note that each follow
    > up response may take approximately 2 business days as the support
    > professional working with you may need further investigation to reach the
    > most efficient resolution. The offering is not appropriate for situations
    > that require urgent, real-time or phone-based interactions or complex
    > project analysis and dump analysis issues. Issues of this nature are best
    > handled working with a dedicated Microsoft Support Engineer by contacting
    > Microsoft Customer Support Services (CSS) at
    > http://msdn.microsoft.com/subscriptions/support/default.aspx.
    > ==================================================
    >
    > This posting is provided "AS IS" with no warranties, and confers no rights.
    >
    >
    >
    >
    c676228, Feb 7, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alf P. Steinbach
    Replies:
    0
    Views:
    423
    Alf P. Steinbach
    Aug 18, 2003
  2. John Harrison
    Replies:
    4
    Views:
    6,914
    Default User
    Aug 19, 2003
  3. Icosahedron
    Replies:
    8
    Views:
    640
    Vivek
    Aug 21, 2003
  4. Venkat
    Replies:
    4
    Views:
    962
    Venkat
    Dec 5, 2003
  5. Kenneth Brody

    Two-dimensional array to array of arrays

    Kenneth Brody, Dec 21, 2006, in forum: C Programming
    Replies:
    2
    Views:
    496
    Simon Biber
    Dec 21, 2006
Loading...

Share This Page