a two dimensional array question

C

c676228

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
 
L

Luke Zhang [MSFT]

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.
 
C

c676228

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
 
L

Luke Zhang [MSFT]

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top