Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Function to remove numbers from address field

 
Logged in as: Guest
arrSession:exec spGetSession 2,3,175
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> ASP >> Function to remove numbers from address field
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Function to remove numbers from address field - 6/16/2001 4:10:06 AM   
  pia

 

Posts: 13
Score: 0
Joined: 5/31/2001
From: USA
Status: offline
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!
 
 
Post #: 1
 
 Re: Function to remove numbers from address field - 6/16/2001 4:11:08 AM   
  nukeboy

 

Posts: 10
Score: 0
Joined: 5/22/2001
From: USA
Status: offline
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

(in reply to pia)
 
 
Post #: 2
 
 Re: Function to remove numbers from address field - 6/16/2001 4:11:56 AM   
  drkesrel

 

Posts: 11
Score: 0
Joined: 5/23/2001
From: USA
Status: offline
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

(in reply to pia)
 
 
Post #: 3
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> ASP >> Function to remove numbers from address field Page: [1]
Jump to:





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
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts