Function to remove numbers from address field

Author Message
pia

  • Total Posts : 13
  • Scores: 0
  • Reward points : 0
  • Joined: 5/31/2001
  • Location: USA
  • Status: offline
Function to remove numbers from address field Saturday, June 16, 2001 5:10 AM (permalink)
0
I am building a web application based on an Access database. One of the reports I need to port to ASP is based
on a query that includes a function that is stored in a module within the Access database. The function removes
the numbers from the address field so that this field can be sorted by street name.

The SQL statement is my asp page is as follows:

sql = "SELECT DISTINCTROW qryLastVisitDate.ShopName, qryLastVisitDate.ShopCity,
qryLastVisitDate.ShopAddress, qryLastVisitDate.ShopContact1FirstName, qryLastVisitDate.LastOfVisitDate "
sql = sql & "FROM tblVisits, qryLastVisitDate "
sql = sql & "ORDER BY getNoNums([ShopAddress]);"

The function in the Access module is as follows:

Public Function getNoNums(addr As String) As String

Dim i As Integer, t As String
addr = Trim(addr)
If Len(addr) Then


For i = 1 To Len(addr)


t = Mid(addr, i, 1)


If Asc(t) > 57 Or Asc(t) < 48 Then getNoNums = getNoNums & t


Next i
Else


getNoNums = ""
End If
End Function

When I copied the function into my asp page, of course there were errors. Can anybody help me to make this
code work in asp?

Thank you very much!

 
#1
    nukeboy

    • Total Posts : 10
    • Scores: 0
    • Reward points : 0
    • Joined: 5/23/2001
    • Location: USA
    • Status: offline
    Re: Function to remove numbers from address field Saturday, June 16, 2001 5:11 AM (permalink)
    0
    Without testing it, there is a couple of changes you will need to make for it to work with ASP. These are:

    Change

    Public Function getNoNums(addr As String) As String


    to

    Function getNoNums(addr)' As String

    and

    Dim i As Integer, t As String


    to

    Dim i 'As Integer
    Dim t 'As String

     
    #2
      drkesrel

      • Total Posts : 11
      • Scores: 0
      • Reward points : 0
      • Joined: 5/23/2001
      • Location: USA
      • Status: offline
      Re: Function to remove numbers from address field Saturday, June 16, 2001 5:11 AM (permalink)
      0
      The For next loop is not correct. Also the else within the if is not required as the line:-

      getNoNums =""

      is reseting the variable.

      Change the loop to:-

      For i = 1 To Len(addr)
      t = Mid(addr, i, 1)

      If Asc(t) > 57 Or Asc(t) < 48 Then
      getNoNums = getNoNums & t
      end if
      Next i

       
      #3

        Online Bookmarks Sharing: Share/Bookmark

        Jump to:

        Current active users

        There are 0 members and 1 guests.

        Icon Legend and Permission

        • New Messages
        • No New Messages
        • Hot Topic w/ New Messages
        • Hot Topic w/o New Messages
        • Locked w/ New Messages
        • Locked w/o New Messages
        • Read Message
        • Post New Thread
        • Reply to message
        • Post New Poll
        • Submit Vote
        • Post reward post
        • Delete my own posts
        • Delete my own threads
        • Rate post

        2000-2012 ASPPlayground.NET Forum Version 3.9